#include <typedefs.h>
#include <error.h>
#include <p_wkfile.h>
#include <p_status.h>
#include <pcb_defs.h>
#include <list_mgmt.h>
#include <keyboard.h>

#include "proto.h"
#include "p_tcomp.h"
#include "pneu_int.h"



#define DET_EEPROM_SIZE 256
#define NUM_DET_TYPES 5
#define EEPROM_DEF_SIZE  27


#define D_DT DEFAULT_DT
#define D_DV (U_INT16)DEFAULT_DV
#define D_25 DEFAULT_V25C
#define V_DET REQUIRED_DET_VERSION



const struct { U_INT16 value; BIT8 definition[EEPROM_DEF_SIZE]; }  Det_EEPROM_Default[DET_EEPROM_SIZE ] = {

/*#!inc_addr*/

  /* standard header */

  /*       ----+----1----+----2----+-               ----+----1----+----2----+-               ----+----1----+----2----+-  */
{ 0x0000, "00 Module Checksum        " },{ V_DET,  "01 Version   U.F          " },{ 0x0000, "02 Module Type            " },
{ 0xc282, "03 Build Date             " },{ 0x0000, "04 Serial Number High     " },{ 0x0001, "05 Serial Number Low      " },
{ D_DV,   "06 Thermistor delta volts " },{ D_DT,   "07 Thermistor delta temp  " },{ D_25,   "08 Thermistor V 25C       " },


   /* sensor definitions  */

{ 0xa854, "09 P Sensor Range     Fuel" },{ 0xa854, "0a P Sensor Range     Util" },{ 0xa854, "0b P Sensor Range      Mug" },
{ 0x3333, "0c Fact PS 25C Offset Fuel" },{ 0x3333, "0d Fact PS 25C Offset Util" },{ 0x3333, "0e Fact PS 25C Offset  Mug" },
{ 0x0000, "0f Fact PS dOffset/dT Fuel" },{ 0x0000, "10 Fact PS dOffset/dT Util" },{ 0x0000, "11 Fact PS dOffset/dT  Mug" },
{ 0x9999, "12 Fact PS Span       Fuel" },{ 0x9999, "13 Fact PS Span       Util" },{ 0x9999, "14 Fact PS Span        Mug" },
{ 0x0000, "15 Fact PS dSpan/dT   Fuel" },{ 0x0000, "16 Fact PS dSpan/dT   Util" },{ 0x0000, "17 Fact PS dSpan/dT    Mug" },

   /* internal unit scalings */


{ 0x00a0, "18 Pres Scaling d/cm2 Fuel" },{ 0x00a0, "19 Pres Scaling d/cm2 Util" },{ 0x00a0, "   Pres Scaling d/cm2  Mug" },
{ 0x0012, "1b Flow Scaling #Bits Fuel" },{ 0x0012, "1c Flow Scaling #Bits Util" },{ 0x0012, "1d Flow Scaling #Bits  Mug" },


   /* user calib  */

{ 0x0000, "1e User Calib State       " },{ 0x0000, "1f User Calib Date1       " },{ 0x0000, "20 User Calib Date2       " },
{ 0x0000, "21 User F Calib OffsetFuel" },{ 0x0000, "22 User F Calib OffsetUtil" },{ 0x0000, "23 User F Calib Offset Mug" },
{ 0x4000, "24 User F Calib Gain  Fuel" },{ 0x4000, "25 User F Calib Gain  Util" },{ 0x4000, "26 User F Calib Gain   Mug" },
{ 0x0000, "27 User F Calib Pres  Fuel" },{ 0x0000, "28 User F Calib Flow  Util" },{ 0x0000, "29 User F Calib Flow   Mug" },

   /* factory calib  */

{ 0x4000, "2a Fact PS Pres Gain  Fuel" },{ 0x4000, "2b Fact PS Pres Gain  Util" },{ 0x4000, "2c Fact PS Pres Gain   Mug" },
{ 0x0000, "2d Fact P Calib OffsetFuel" },{ 0x0000, "2e Fact P Calib OffsetUtil" },{ 0x0000, "2f Fact P Calib Offset Mug" },

   /* factory pid terms */

{ 0xffff, "30 Fact   N2      Fuel  I " },{ 0xffff, "31 Fact   N2/ Air Util  I " },{ 0xffff, "32 Fact   N2       Mug  I " },
{ 0xffff, "33 Fact   N2      Fuel  P " },{ 0xffff, "34 Fact   N2/ Air Util  P " },{ 0xffff, "35 Fact   N2       Mug  P " },
{ 0xffff, "36 Fact   N2      Fuel  D " },{ 0xffff, "37 Fact   N2/ Air Util  D " },{ 0xffff, "38 Fact   N2       Mug  D " },
{ 0xffff, "39 Fact   N2      Fuel NL " },{ 0xffff, "3a Fact   N2/ Air Util NL " },{ 0xffff, "3b Fact   N2       Mug NL " },

{ 0xffff, "3c Fact   H2      Fuel  I " },{ 0xffff, "3d Fact   H2      Util  I " },{ 0xffff, "3e Fact   H2       Mug  I " },
{ 0xffff, "3f Fact   H2      Fuel  P " },{ 0xffff, "40 Fact   H2      Util  P " },{ 0xffff, "41 Fact   H2       Mug  P " },
{ 0xffff, "42 Fact   H2      Fuel  D " },{ 0xffff, "43 Fact   H2      Util  D " },{ 0xffff, "44 Fact   H2       Mug  D " },
{ 0xffff, "45 Fact   H2      Fuel NL " },{ 0xffff, "46 Fact   H2      Util NL " },{ 0xffff, "47 Fact   H2       Mug NL " },

{ 0xffff, "48 Fact   He      Fuel  I " },{ 0xffff, "49 Fact   He/  O2 Util  I " },{ 0xffff, "4a Fact   He       Mug  I " },
{ 0xffff, "4b Fact   He      Fuel  P " },{ 0xffff, "4c Fact   He/  O2 Util  P " },{ 0xffff, "4d Fact   He       Mug  P " },
{ 0xffff, "4e Fact   He      Fuel  D " },{ 0xffff, "4f Fact   He/  O2 Util  D " },{ 0xffff, "50 Fact   He       Mug  D " },
{ 0xffff, "51 Fact   He      Fuel NL " },{ 0xffff, "52 Fact   He/  O2 Util NL " },{ 0xffff, "53 Fact   He       Mug NL " },

{ 0xffff, "54 Fact ArMe      Fuel  I " },{ 0xffff, "55 Fact ArMe/  Ar Util  I " },{ 0xffff, "56 Fact ArMe/  Ar  Mug  I " },
{ 0xffff, "57 Fact ArMe      Fuel  P " },{ 0xffff, "58 Fact ArMe/  Ar Util  P " },{ 0xffff, "59 Fact ArMe/  Ar  Mug  P " },
{ 0xffff, "5a Fact ArMe      Fuel  D " },{ 0xffff, "5b Fact ArMe/  Ar Util  D " },{ 0xffff, "5c Fact ArMe/  Ar  Mug  D " },
{ 0xffff, "5d Fact ArMe      Fuel NL " },{ 0xffff, "5e Fact ArMe/  Ar Util NL " },{ 0xffff, "5f Fact ArMe/  Ar  Mug NL " },

   /* user pid terms 60h...8fh ; prior to GowMac OEM det support ; i.e. to including A.03.03  */

{ 0xffff, "60 CTL5_Label_chars1_2    " },{ 0xffff, "61 CTL5_Label_chars3_4    " },{ 0xffff, "62 CTL5_Label_chars5_6    " },
{ 0xffff, "63 CTL5_Label_chars7_8    " },{ 0xffff, "64 CTL5_Label_chars9_10   " },{ 0xffff, "65 CTL5_Label_chars11_12  " },
{ 0xffff, "66 XTL6_Label_chars1_2    " },{ 0xffff, "67 XTL6_Label_chars3_4    " },{ 0xffff, "68 XTL6_Label_chars5_6    " },
{ 0xffff, "69 XTL6_Label_chars7-8    " },{ 0xffff, "6a XTL6_Label_chars9_10   " },{ 0xffff, "6b XTL6_Label_chars11_12  " },

{ 0xffff, "6c XTL7_Label_chars1_2    " },{ 0xffff, "6d XTL7_Label_chars3_4    " },{ 0xffff, "6e XTL7_Label_chars5_6    " },
{ 0xffff, "6f XTL7_Label_chars7-8    " },{ 0xffff, "70 XTL7_Label_chars9_10   " },{ 0xffff, "71 XTL7_Label_chars11_12  " },
{ 0xffff, "72 CTL1_2_PULSE_Time      " },{ 0xffff, "73 CTL3_4_PULSE_Time      " },{ 0xffff, "74 CTL5_PULSE_Time        " },
{ 0xffff, "75 OEM_GC_LABEL_chars1_2  " },{ 0xffff, "76 OEM_GC_LABEL_chars3_4  " },{ 0xffff, "77 OEM_GC_LABEL_chars5_6  " },

{ 0xffff, "78 OEM_GC_LABEL_chars7_8  " },{ 0xffff, "79 OEM_GC_LABEL_chars9_10 " },{ 0xffff, "7a OEM_GC_LABEL_chars11_12" },
{ 0xffff, "7b OEM_GC_LABEL_chars13_14" },{ 0xffff, "7c OEM_GC_LABEL_chars15_16" },{ 0xffff, "7d OEM_GC_LABEL_chars17_18" },
{ 0xffff, "7e OEM_GC_LABEL_chars19_20" },{ 0xffff, "7f OEMDiag1LabelChars1_2  " },{ 0xffff, "80 OEMDiag1LabelChars3_4  " },
{ 0xffff, "81 OEMDiag1LabelChars5_6  " },{ 0xffff, "82 OEMDiag1LabelChars7_8  " },{ 0xffff, "83 OEMDiag1LabelChars9_10 " },

{ 0xffff, "84 OEMDiag1LabelCHars11_12" },{ 0xffff, "85 OEMDiag2LabelChars1_2  " },{ 0xffff, "86 OEMDiag2LabelChars3_4  " },
{ 0xffff, "87 OEMDiag2LabelChars5_6  " },{ 0xffff, "88 OEMDiag2LabelChars7_8  " },{ 0xffff, "89 OEMDiag2LabelChars9_10 " },
{ 0xffff, "8a OEMDiag2LabelCHars11_12" },{ 0xffff, "8b                        " },{ 0xffff, "8c                        " },
{ 0xffff, "8d                        " },{ 0xffff, "8e                        " },{ 0xffff, "8f                        " },


   /* frit and gas characteristic parameters ; Note that OEM det flow mode uses frit modeling !! */

{ 0x000a, "90 Fuel H2 Frit 1 High    " },{ 0x003a, "91 Util Air/N2 Frit 1 High" },{ 0x0004, "92 MUG  N2 Frit 1 High    " },
{ 0x0880, "93 Fuel H2 Frit 1 Low     " },{ 0x1080, "94 Util Air/N2 Frit 1 Low " },{ 0x9880, "95 MUG  N2 Frit 1 Low     " },
{ 0x0000, "96 Fuel H2 Frit 2 High    " },{ 0x0003, "97 Util Air/N2 Frit 2 High" },{ 0x0000, "98 MUG  N2 Frit 2 High    " },
{ 0x8880, "99 Fuel H2 Frit 2 Low     " },{ 0x9080, "9a Util Air/N2 Frit 2 Low " },{ 0x9880, "9b MUG  N2 Frit 2 Low     " },

{ 0x0000, "9c Fuel H2 Max Flow       " },{ 0x0000, "9d Util Air/N2 Max Flow   " },{ 0x0000, "9e MUG  N2 Max Flow       " },
{ 0x0000, "9f                        " },{ 0x0004, "a0 Util O2/He Frit 1 High " },{ 0x0002, "a1 MUG  He Frit 1 High    " },
{ 0x0000, "a2                        " },{ 0x9100, "a3 Util O2/He Frit 1 Low  " },{ 0x9900, "a4 MUG  He Frit 1 Low     " },
{ 0x0000, "a5                        " },{ 0x0000, "a6 Util O2/He Frit 2 High " },{ 0x0000, "a7 MUG  He Frit 2 High    " },

{ 0x0000, "a8                        " },{ 0x1100, "a9 Util O2/He Frit 2 Low  " },{ 0x9900, "aa MUG  He Frit 2 Low     " },
{ 0x0000, "ab                        " },{ 0x0000, "ac Util O2/He Max Flow    " },{ 0x0000, "ad MUG  He Max Flow       " },
{ 0x0000, "ae                        " },{ 0x0033, "af Util H2/ArMe Frit1 High" },{ 0x0004, "b0 MUG  H2/ArMe Frit1 High" },
{ 0x0000, "b1                        " },{ 0x9180, "b2 Util H2/ArMe Frit1 Low " },{ 0x9980, "b3 MUG  H2/ArMe Frit1 Low " },

{ 0x0000, "b4                        " },{ 0x0002, "b5 Util H2/ArMe Frit2 High" },{ 0x0000, "b6 MUG  H2/ArMe Frit2 High" },
{ 0x0000, "b7                        " },{ 0x9180, "b8 Util H2/ArMe Frit2 Low " },{ 0x9980, "b9 MUG  H2/ArMe Frit2 Low " },
{ 0x0000, "ba OEM_RdyPoll&DiagFilters" },{ 0x0000, "bb Util H2/ArMe Max Flow  " },{ 0x0000, "bc MUG  H2/ArMe Max Flow  " },
{ 0x0000, "bd OEM_Diag2_Offset_Valu  " },{ 0x0004, "be Util Ar Frit 1 High    " },{ 0x0004, "bf MUG  Ar Frit 1 High    " },

{ 0x0000, "c0 OEM_Diag2_Mlpyr&Divdr  " },{ 0x9200, "c1 Util Ar Frit 1 Low     " },{ 0x9a00, "c2 MUG  Ar Frit 1 Low     " },
{ 0x0000, "c3 OEM_Diag1_Offset_Valu  " },{ 0x0000, "c4 Util Ar Frit 2 High    " },{ 0x0000, "c5 MUG  Ar Frit 2 High    " },
{ 0x0000, "c6 OEM_Diag1_Mlpyr&Divdr  " },{ 0x9200, "c7 Util Ar Frit 2 Low     " },{ 0x9a00, "c8 MUG  Ar Frit 2 Low     " },
{ 0x0000, "c9 Chan 2 Min Flow        " },{ 0x0000, "ca Util Ar Max Flow       " },{ 0x0000, "cb MUG  Ar Max Flow       " },

 /* Gas 1  label */
{ 0x0000, "cc Gas1 label bytes 0,1   " },{ 0x0000, "cd Gas1 label bytes 2,3   " },{ 0x0000, "ce Gas1 label bytes 4,5   " },
{ 0x0000, "cf Gas1 label bytes 6,7   " },


  /* Gas 2 label */
{ 0x0000, "d0 Gas2 label bytes 0,1   " },{ 0x0000, "d1 Gas2 label bytes 2,3   " },{ 0x0000, "d2 Gas2 label bytes 4,5   " },
{ 0x0000, "d3 Gas2 label bytes 6,7   " },

  /* Gas 3 label */
{ 0x0000, "d4 Gas3 label bytes 0,1   " },{ 0x0000, "d5 Gas3 label bytes 2,3   " },{ 0x0000, "d6 Gas3 label bytes 4,5   " },
{ 0x0000, "d7 Gas3 label bytes 6,7   " },


  /* control line 1 */
{ 0x0000, "d8 Ctl1 label bytes 0,1   " },{ 0x0000, "d9 Ctl1 label bytes 2,3   " },{ 0x0000, "da Ctl1 label bytes 4,5   " },
{ 0x0000, "db Ctl1 label bytes 6,7   " },{ 0x0000, "dc Ctl1 label bytes 8,9   " },{ 0x0000, "dd Ctl1 label bytes 10,11 " },

  /* control line 2 */
{ 0x0000, "de Ctl2 label bytes 0,1   " },{ 0x0000, "df Ctl2 label bytes 2,3   " },{ 0x0000, "e0 Ctl2 label bytes 4,5   " },
{ 0x0000, "e1 Ctl2 label bytes 6,7   " },{ 0x0000, "e2 Ctl2 label bytes 8,9   " },{ 0x0000, "e3 Ctl2 label bytes 10,11 " },

  /* control line 3 */
{ 0x0000, "e4 Ctl3 label bytes 0,1   " },{ 0x0000, "e5 Ctl3 label bytes 2,3   " },{ 0x0000, "e6 Ctl3 label bytes 4,5   " },
{ 0x0000, "e7 Ctl3 label bytes 6,7   " },{ 0x0000, "e8 Ctl3 label bytes 8,9   " },{ 0x0000, "e9 Ctl3 label bytes 10,11 " },

  /* control line 4 */
{ 0x0000, "ea Ctl4 label bytes 0,1   " },{ 0x0000, "eb Ctl4 label bytes 2,3   " },{ 0x0000, "ec Ctl4 label bytes 4,5   " },
{ 0x0000, "ed Ctl4 label bytes 6,7   " },{ 0x0000, "ee Ctl4 label bytes 8,9   " },{ 0x0000, "ef Ctl4 label bytes 10,11 " },

  /* format for control lines */
{ 0x0000, "f0  Cntl Lines 1&2 format " },{ 0x0000, "f1 Cntl Lines 3&4 format  " },

  /* allowed gas masks */
{ 0x0000, "f2  Fuel - allowable gases" },{ 0x0000, "f3  Util - allowable gases" },{ 0x0000, "f4  Mug  - allowable gases" },

  /* unused location */
{ 0x0000, "f5  CPF Pneu Flag (1 bit) " },

  /* thermal constants */
{ 0x0000, "f6 Thermal1: P, I         " },{ 0x0000, "f7 Thermal2: D,minTemp    " },{ 0x0000, "f8 Thermal3:maxT,snsr,freq" },
{ 0x0000, "f9 Thermal4: rate,cyo,conf" },{ 0x0000, "fa Thermal5: div-P,I,D    " },{ 0x0000, "fb Thermal6: CtlErr,IntPwr" },

  /* detector id */
{ 0x0000, "fc Det Title  bytes 0,1   " },{ 0x0000, "fd Det title  bytes 2,3   " },{ 0x0000, "fe Det title  bytes 4,5   " },


{ 0x0000, "ff Test Station ID Number " }

/*#!inc_addr*/


};

static const U_INT16 Factory_Det_Pid_Address_Table[8/*gas*/][4/*term*/][3/*ch*/]= {
 /* normal det mapping */
{{              0,              FACT_CH_2_N2_I_GAIN,    FACT_CH_3_N2_I_GAIN     },
 {              0,              FACT_CH_2_N2_P_GAIN,    FACT_CH_3_N2_P_GAIN     },
 {              0,              FACT_CH_2_N2_D_GAIN,    FACT_CH_3_N2_D_GAIN     },
 {              0,              FACT_CH_2_N2_NL_GAIN,   FACT_CH_3_N2_NL_GAIN    }},

{{ FACT_CH_1_H2_I_GAIN,         FACT_CH_2_H2_I_GAIN,    FACT_CH_3_H2_I_GAIN     },
 { FACT_CH_1_H2_P_GAIN,         FACT_CH_2_H2_P_GAIN,    FACT_CH_3_H2_P_GAIN     },
 { FACT_CH_1_H2_D_GAIN,         FACT_CH_2_H2_D_GAIN,    FACT_CH_3_H2_D_GAIN     },
 { FACT_CH_1_H2_NL_GAIN,        FACT_CH_2_H2_NL_GAIN,   FACT_CH_3_H2_NL_GAIN    }},

{{              0,              FACT_CH_2_He_I_GAIN,    FACT_CH_3_He_I_GAIN     },
 {              0,              FACT_CH_2_He_P_GAIN,    FACT_CH_3_He_P_GAIN     },
 {              0,              FACT_CH_2_He_D_GAIN,    FACT_CH_3_He_D_GAIN     },
 {              0,              FACT_CH_2_He_NL_GAIN,   FACT_CH_3_He_NL_GAIN    }},

{{              0,              FACT_CH_2_ArMe_I_GAIN,  FACT_CH_3_ArMe_I_GAIN   },
 {              0,              FACT_CH_2_ArMe_P_GAIN,  FACT_CH_3_ArMe_P_GAIN   },
 {              0,              FACT_CH_2_ArMe_D_GAIN,  FACT_CH_3_ArMe_D_GAIN   },
 {              0,              FACT_CH_2_ArMe_NL_GAIN, FACT_CH_3_ArMe_NL_GAIN  }},

{{              0,              FACT_CH_2_O2_I_GAIN,            0               },
 {              0,              FACT_CH_2_O2_P_GAIN,            0               },
 {              0,              FACT_CH_2_O2_D_GAIN,            0               },
 {              0,              FACT_CH_2_O2_NL_GAIN,           0               }},

{{              0,              FACT_CH_2_Air_I_GAIN,           0               },
 {              0,              FACT_CH_2_Air_P_GAIN,           0               },
 {              0,              FACT_CH_2_Air_D_GAIN,           0               },
 {              0,              FACT_CH_2_Air_NL_GAIN,          0               }},

{{              0,              FACT_CH_2_Ar_I_GAIN,    FACT_CH_3_Ar_I_GAIN     },
 {              0,              FACT_CH_2_Ar_P_GAIN,    FACT_CH_3_Ar_P_GAIN     },
 {              0,              FACT_CH_2_Ar_D_GAIN,    FACT_CH_3_Ar_D_GAIN     },
 {              0,              FACT_CH_2_Ar_NL_GAIN,   FACT_CH_3_Ar_NL_GAIN    }},

{{              0,                      0,                      0               },
 {              0,                      0,                      0               },
 {              0,                      0,                      0               },
 {              0,                      0,                      0               }} };

static const U_INT16 User_Det_Pid_Address_Table[/*gas*/][4/*term*/][3/*ch*/]= {

{{              0,              USER_CH_2_N2_I_GAIN,    USER_CH_3_N2_I_GAIN     },
 {              0,              USER_CH_2_N2_P_GAIN,    USER_CH_3_N2_P_GAIN     },
 {              0,              USER_CH_2_N2_D_GAIN,    USER_CH_3_N2_D_GAIN     },
 {              0,              USER_CH_2_N2_NL_GAIN,   USER_CH_3_N2_NL_GAIN    }},

{{ USER_CH_1_H2_I_GAIN,         USER_CH_2_H2_I_GAIN,    USER_CH_3_H2_I_GAIN     },
 { USER_CH_1_H2_P_GAIN,         USER_CH_2_H2_P_GAIN,    USER_CH_3_H2_P_GAIN     },
 { USER_CH_1_H2_D_GAIN,         USER_CH_2_H2_D_GAIN,    USER_CH_3_H2_D_GAIN     },
 { USER_CH_1_H2_NL_GAIN,        USER_CH_2_H2_NL_GAIN,   USER_CH_3_H2_NL_GAIN    }},

{{              0,              USER_CH_2_He_I_GAIN,    USER_CH_3_He_I_GAIN     },
 {              0,              USER_CH_2_He_P_GAIN,    USER_CH_3_He_P_GAIN     },
 {              0,              USER_CH_2_He_D_GAIN,    USER_CH_3_He_D_GAIN     },
 {              0,              USER_CH_2_He_NL_GAIN,   USER_CH_3_He_NL_GAIN    }},

{{              0,              USER_CH_2_ArMe_I_GAIN,  USER_CH_3_ArMe_I_GAIN   },
 {              0,              USER_CH_2_ArMe_P_GAIN,  USER_CH_3_ArMe_P_GAIN   },
 {              0,              USER_CH_2_ArMe_D_GAIN,  USER_CH_3_ArMe_D_GAIN   },
 {              0,              USER_CH_2_ArMe_NL_GAIN, USER_CH_3_ArMe_NL_GAIN  }},

{{              0,              USER_CH_2_O2_I_GAIN,            0               },
 {              0,              USER_CH_2_O2_P_GAIN,            0               },
 {              0,              USER_CH_2_O2_D_GAIN,            0               },
 {              0,              USER_CH_2_O2_NL_GAIN,           0               }},

{{              0,              USER_CH_2_Air_I_GAIN,           0               },
 {              0,              USER_CH_2_Air_P_GAIN,           0               },
 {              0,              USER_CH_2_Air_D_GAIN,           0               },
 {              0,              USER_CH_2_Air_NL_GAIN,          0               }},

{{              0,              USER_CH_2_Ar_I_GAIN,    USER_CH_3_Ar_I_GAIN     },
 {              0,              USER_CH_2_Ar_P_GAIN,    USER_CH_3_Ar_P_GAIN     },
 {              0,              USER_CH_2_Ar_D_GAIN,    USER_CH_3_Ar_D_GAIN     },
 {              0,              USER_CH_2_Ar_NL_GAIN,   USER_CH_3_Ar_NL_GAIN    }},

{{              0,                      0,                      0               },
 {              0,                      0,                      0               },
 {              0,                      0,                      0               },
 {              0,                      0,                      0               }}
 };



/**begin_proto**/

U_INT16 GetFactDetPidEepromAddress( GAS_TYPE gas, U_INT8 sensor_position, U_INT8 term )

/**end_proto**/
{
    return Factory_Det_Pid_Address_Table [ (U_INT8)gas ] [ term ] [ sensor_position -1 ];
}

/**begin_proto**/

U_INT16 GetUserDetPidEepromAddress( GAS_TYPE gas, U_INT8 sensor_position, U_INT8 term )

/**end_proto**/
{
    return User_Det_Pid_Address_Table [ (U_INT8)gas ] [ term ] [ sensor_position -1 ];
}



/**begin_proto**/
extern const U_INT16 Frit_Parm_Address_Table [/*gas*/][5/*Parms*/][3/*ch*/];
/**end_proto**/


const U_INT16 Frit_Parm_Address_Table [/*gas*/][5/*Parms*/][3/*ch*/]= {

{{               0,             GAS_2_N2_FRIT_1_WORD_1,         GAS_3_N2_FRIT_1_WORD_1  },
 {               0,             GAS_2_N2_FRIT_1_WORD_2,         GAS_3_N2_FRIT_1_WORD_2  },
 {               0,             GAS_2_N2_FRIT_2_WORD_1,         GAS_3_N2_FRIT_2_WORD_1  },
 {               0,             GAS_2_N2_FRIT_2_WORD_2,         GAS_3_N2_FRIT_2_WORD_2  },
 {               0,             GAS_2_N2_MAX_FLOW,              GAS_3_N2_MAX_FLOW       }},

{{ GAS_1_H2_FRIT_1_WORD_1,      GAS_2_H2_FRIT_1_WORD_1,         GAS_3_H2_FRIT_1_WORD_1  },
 { GAS_1_H2_FRIT_1_WORD_2,      GAS_2_H2_FRIT_1_WORD_2,         GAS_3_H2_FRIT_1_WORD_2  },
 { GAS_1_H2_FRIT_2_WORD_1,      GAS_2_H2_FRIT_2_WORD_1,         GAS_3_H2_FRIT_2_WORD_1  },
 { GAS_1_H2_FRIT_2_WORD_2,      GAS_2_H2_FRIT_2_WORD_2,         GAS_3_H2_FRIT_2_WORD_2  },
 { GAS_1_H2_MAX_FLOW,           GAS_2_H2_MAX_FLOW,              GAS_3_H2_MAX_FLOW       }},

{{               0,             GAS_2_He_FRIT_1_WORD_1,         GAS_3_He_FRIT_1_WORD_1  },
 {               0,             GAS_2_He_FRIT_1_WORD_2,         GAS_3_He_FRIT_1_WORD_2  },
 {               0,             GAS_2_He_FRIT_2_WORD_1,         GAS_3_He_FRIT_2_WORD_1  },
 {               0,             GAS_2_He_FRIT_2_WORD_2,         GAS_3_He_FRIT_2_WORD_2  },
 {               0,             GAS_2_He_MAX_FLOW,              GAS_3_He_MAX_FLOW       }},

{{               0,             GAS_2_ArMe_FRIT_1_WORD_1,       GAS_3_ArMe_FRIT_1_WORD_1        },
 {               0,             GAS_2_ArMe_FRIT_1_WORD_2,       GAS_3_ArMe_FRIT_1_WORD_2        },
 {               0,             GAS_2_ArMe_FRIT_2_WORD_1,       GAS_3_ArMe_FRIT_2_WORD_1        },
 {               0,             GAS_2_ArMe_FRIT_2_WORD_2,       GAS_3_ArMe_FRIT_2_WORD_2        },
 {               0,             GAS_2_ArMe_MAX_FLOW,            GAS_3_ArMe_MAX_FLOW             }},

{{              0,              GAS_2_O2_FRIT_1_WORD_1,                 0               },
 {              0,              GAS_2_O2_FRIT_1_WORD_2,                 0               },
 {              0,              GAS_2_O2_FRIT_2_WORD_1,                 0               },
 {              0,              GAS_2_O2_FRIT_2_WORD_2,                 0               },
 {              0,              GAS_2_O2_MAX_FLOW,                      0               }},

{{              0,              GAS_2_Air_FRIT_1_WORD_1,                0               },
 {              0,              GAS_2_Air_FRIT_1_WORD_2,                0               },
 {              0,              GAS_2_Air_FRIT_2_WORD_1,                0               },
 {              0,              GAS_2_Air_FRIT_2_WORD_2,                0               },
 {              0,              GAS_2_Air_MAX_FLOW,                     0               }},

{{              0,              GAS_2_Ar_FRIT_1_WORD_1,         GAS_3_Ar_FRIT_1_WORD_1  },
 {              0,              GAS_2_Ar_FRIT_1_WORD_2,         GAS_3_Ar_FRIT_1_WORD_2  },
 {              0,              GAS_2_Ar_FRIT_2_WORD_1,         GAS_3_Ar_FRIT_2_WORD_1  },
 {              0,              GAS_2_Ar_FRIT_2_WORD_2,         GAS_3_Ar_FRIT_2_WORD_2  },
 {              0,              GAS_2_Ar_MAX_FLOW,              GAS_3_Ar_MAX_FLOW       }},

{{              0,                      0,                      0               },
 {              0,                      0,                      0               },
 {              0,                      0,                      0               },
 {              0,                      0,                      0               }}
 };


static const UPDATE_TABLE_ENTRY  Det_Min_Flow_Update[] = {

  { SAVE_WORD,  0x01,   0,      0 },       /* scribble version in case of failure */
  { INIT_WORD,  0x0000, 0x01,   0 },

  { SKIP_NE,    0x0212, 0x02,  1  },       /* if EPC TCD then */
/*{ SKIP_NE,    0x021a, 0x02,  1  },       /* if EPC LDID then */

      { INIT_WORD,      5, 0xc9,   0 },         /* Ch2, AnyGas, 5. ml (Ch. 3 for LDID) */

  { RESTORE_WORD,0,     0x01,   0 },       /* rewrite version  */

  { END,        0,      0,      0 } } ;



static const UPDATE_TABLE_ENTRY  Det_Max_Flow_Update[] = {

  { SAVE_WORD,  0x01,   0,      0 },       /* scribble version in case of failure */
  { INIT_WORD,  0x0000, 0x01,   0 },

  { SKIP_NE,    0x0211, 0x02,  12 },       /* if EPC FID then */

      { INIT_WORD,    100, 0x9c,   0 },         /* H2   100mL  Fuel */
      { INIT_WORD,      0, 0xab,   0 },         /*             Fuel */
      { INIT_WORD,      0, 0xba,   0 },         /*             Fuel */
      { INIT_WORD,      0, 0xc9,   0 },         /*             Fuel */

      { INIT_WORD,    800, 0x9d,   0 },         /* Air  800mL  Util */
      { INIT_WORD,      0, 0xac,   0 },         /*             Util */
      { INIT_WORD,      0, 0xbb,   0 },         /*             Util */
      { INIT_WORD,      0, 0xca,   0 },         /*             Util */

      { INIT_WORD,    100, 0x9e,   0 },         /* N2   100mL  Mug  */
      { INIT_WORD,    100, 0xad,   0 },         /* He   100mL  Mug  */
      { INIT_WORD,      0, 0xbc,   0 },         /*             Mug  */
      { INIT_WORD,      0, 0xcb,   0 },         /*             Mug  */


  { SKIP_NE,    0x0212, 0x02,  12 },       /* if EPC TCD then */

      { INIT_WORD,      0, 0x9c,   0 },         /*             Fuel */
      { INIT_WORD,      0, 0xab,   0 },         /*             Fuel */
      { INIT_WORD,      0, 0xba,   0 },         /*             Fuel */
      { INIT_WORD,      0, 0xc9,   0 },         /*             Fuel */

      { INIT_WORD,    100, 0x9d,   0 },         /* N2   100mL  Util */
      { INIT_WORD,    100, 0xac,   0 },         /* He   100mL  Util */
      { INIT_WORD,    100, 0xbb,   0 },         /* H2   100mL  Util */
      { INIT_WORD,      0, 0xca,   0 },         /*             Util */

      { INIT_WORD,     10, 0x9e,   0 },         /* N2    10mL  Mug  */
      { INIT_WORD,     12, 0xad,   0 },         /* He    12mL  Mug  */
      { INIT_WORD,     18, 0xbc,   0 },         /* H2    18mL  Mug  */
      { INIT_WORD,      0, 0xcb,   0 },         /*             Mug  */


  { SKIP_EQ,    0x0218, 0x02,   1 },       /* if uECD2 or */
  { SKIP_NE,    0x0217, 0x02,  12 },       /* if uECD then fall thru else jump */

      { INIT_WORD,      0, 0x9c,   0 },         /*             Fuel */
      { INIT_WORD,      0, 0xab,   0 },         /*             Fuel */
      { INIT_WORD,      0, 0xba,   0 },         /*             Fuel */
      { INIT_WORD,      0, 0xc9,   0 },         /*             Fuel */

      { INIT_WORD,      0, 0x9d,   0 },         /* N2    12mL  Util */
      { INIT_WORD,      0, 0xac,   0 },         /*             Util */
      { INIT_WORD,      0, 0xbb,   0 },         /* ArMe  12mL  Util */
      { INIT_WORD,      0, 0xca,   0 },         /*             Util */

      { INIT_WORD,    150, 0x9e,   0 },         /* N2   200mL  Mug  */
      { INIT_WORD,      0, 0xad,   0 },         /*             Mug  */
      { INIT_WORD,    150, 0xbc,   0 },         /* ArMe 200mL  Mug  */
      { INIT_WORD,      0, 0xcb,   0 },         /*             Mug  */

  { SKIP_NE,    0x021a, 0x02,  12 },       /* if EPC LDID then */

      { INIT_WORD,      0, 0x9c,   0 },         /* H2          Fuel */
      { INIT_WORD,      0, 0xab,   0 },         /*             Fuel */
      { INIT_WORD,      0, 0xba,   0 },         /*             Fuel */
      { INIT_WORD,      0, 0xc9,   0 },         /*             Fuel */

      { INIT_WORD,      0, 0x9d,   0 },         /* Air         Util */
      { INIT_WORD,      0, 0xac,   0 },         /*             Util */
      { INIT_WORD,      0, 0xbb,   0 },         /*             Util */
      { INIT_WORD,      0, 0xca,   0 },         /*             Util */

      { INIT_WORD,      0, 0x9e,   0 },         /* N2          Mug  */
      { INIT_WORD,    200, 0xad,   0 },         /* He   200mL  Mug  */
      { INIT_WORD,      0, 0xbc,   0 },         /*             Mug  */
      { INIT_WORD,      0, 0xcb,   0 },         /* Ar          Mug  */


  { SKIP_NE,    0x0213, 0x02,  12 },       /* if EPC ECD then */

      { INIT_WORD,      0, 0x9c,   0 },         /*             Fuel */
      { INIT_WORD,      0, 0xab,   0 },         /*             Fuel */
      { INIT_WORD,      0, 0xba,   0 },         /*             Fuel */
      { INIT_WORD,      0, 0xc9,   0 },         /*             Fuel */

      { INIT_WORD,     12, 0x9d,   0 },         /* N2    12mL  Util */
      { INIT_WORD,      0, 0xac,   0 },         /*             Util */
      { INIT_WORD,     12, 0xbb,   0 },         /* ArMe  12mL  Util */
      { INIT_WORD,      0, 0xca,   0 },         /*             Util */

      { INIT_WORD,    200, 0x9e,   0 },         /* N2   200mL  Mug  */
      { INIT_WORD,      0, 0xad,   0 },         /*             Mug  */
      { INIT_WORD,    200, 0xbc,   0 },         /* ArMe 200mL  Mug  */
      { INIT_WORD,      0, 0xcb,   0 },         /*             Mug  */


  { SKIP_NE,    0x0214, 0x02,  12 },       /* if EPC NPD then */

      { INIT_WORD,     30, 0x9c,   0 },         /* H2    30mL  Fuel */
      { INIT_WORD,      0, 0xab,   0 },         /*             Fuel */
      { INIT_WORD,      0, 0xba,   0 },         /*             Fuel */
      { INIT_WORD,      0, 0xc9,   0 },         /*             Fuel */

      { INIT_WORD,    200, 0x9d,   0 },         /* Air  200mL  Util */
      { INIT_WORD,      0, 0xac,   0 },         /*             Util */
      { INIT_WORD,      0, 0xbb,   0 },         /*             Util */
      { INIT_WORD,      0, 0xca,   0 },         /*             Util */

      { INIT_WORD,    100, 0x9e,   0 },         /* N2   100mL  Mug  */
      { INIT_WORD,    100, 0xad,   0 },         /* He   100mL  Mug  */
      { INIT_WORD,      0, 0xbc,   0 },         /*             Mug  */
      { INIT_WORD,      0, 0xcb,   0 },         /*             Mug  */


  { SKIP_NE,    0x0215, 0x02,  12 },       /* if EPC FPD then */

      { INIT_WORD,    250, 0x9c,   0 },         /* H2   250mL  Fuel */
      { INIT_WORD,      0, 0xab,   0 },         /*             Fuel */
      { INIT_WORD,      0, 0xba,   0 },         /*             Fuel */
      { INIT_WORD,      0, 0xc9,   0 },         /*             Fuel */

      { INIT_WORD,    200, 0x9d,   0 },         /* Air  200mL  Util */
      { INIT_WORD,      0, 0xac,   0 },         /* O2     0mL  Util */
      { INIT_WORD,      0, 0xbb,   0 },         /*             Util */
      { INIT_WORD,      0, 0xca,   0 },         /*             Util */

      { INIT_WORD,    130, 0x9e,   0 },         /* N2   130mL  Mug  */
      { INIT_WORD,    160, 0xad,   0 },         /* He   160mL  Mug  */
      { INIT_WORD,      0, 0xbc,   0 },         /*             Mug  */
      { INIT_WORD,      0, 0xcb,   0 },         /*             Mug  */


  { RESTORE_WORD,0,     0x01,   0 },       /* rewrite version  */

  { END,        0,      0,      0 } };


/**begin_proto**/

void WriteDetMinFlows( U_INT8 module_number )

/**end_proto**/
{
   UpdateEeprom( module_number, (pUPDATE_TABLE)Det_Min_Flow_Update );
}


/**begin_proto**/

void WriteDetMaxFlows( U_INT8 module_number )

/**end_proto**/
{
   UpdateEeprom( module_number, (pUPDATE_TABLE)Det_Max_Flow_Update );
}



static const UPDATE_TABLE_ENTRY  Det_Ps_Range_Update[] = {

  { SAVE_WORD,  0x01,   0,      0 },       /* scribble version in case of failure */
  { INIT_WORD,  0xff0b, 0x01,   0 },

  { SKIP_NE,    0x0003, 0x09,   2 },       /* if PSensorRange == 15 PSI */
  {  INIT_WORD, 0x327f, 0x09,   0 },           /* set range in IU */
  {  INIT_WORD, 0x0050, 0x18,   0 },           /* set dynes/cm2 */

  { SKIP_NE,    0x0001, 0x09,   2 },       /* if PSensorRange == 100 PSI */
  {  INIT_WORD, 0xa854, 0x09,   0 },           /* set range to 100 psi in IU */
  {  INIT_WORD, 0x00a0, 0x18,   0 },           /* set dynes/cm2 */


  { SKIP_NE,    0x0003, 0x0a,   2 },       /* if PSensorRange == 15 PSI */
  {  INIT_WORD, 0x327f, 0x0a,   0 },           /* set range in IU */
  {  INIT_WORD, 0x0050, 0x19,   0 },           /* set dynes/cm2 */

  { SKIP_NE,    0x0001, 0x0a,   2 },       /* if PSensorRange == 100 PSI */
  {  INIT_WORD, 0xa854, 0x0a,   0 },           /* set range to 100 psi in IU */
  {  INIT_WORD, 0x00a0, 0x19,   0 },           /* set dynes/cm2 */


  { SKIP_NE,    0x0003, 0x0b,   2 },       /* if PSensorRange == 15 PSI */
  {  INIT_WORD, 0x327f, 0x0b,   0 },           /* set range in IU */
  {  INIT_WORD, 0x0050, 0x1a,   0 },           /* set dynes/cm2 */

  { SKIP_NE,    0x0001, 0x0b,   2 },       /* if PSensorRange == 100 PSI */
  {  INIT_WORD, 0xa854, 0x0b,   0 },           /* set range to 100 psi in IU */
  {  INIT_WORD, 0x00a0, 0x1a,   0 },           /* set dynes/cm2 */

  { RESTORE_WORD,0,     0x01,   0 },       /* rewrite version  */

  { END,        0,      0,      0 } };



/**begin_proto**/

void WriteDetPsRange( U_INT8 module_number )

/**end_proto**/
{
   UpdateEeprom( module_number, (pUPDATE_TABLE)Det_Ps_Range_Update );
}


extern U_INT16 EEPROM_Write_Address;
extern U_INT16 EEPROM_Write_Data;

/**begin_proto**/

BIT8 InitDetEEPROM ( U_INT8 module, U_INT16 type, U_INT16 range, U_INT16 scale, U_INT16 snh, U_INT16 snl, U_INT16 bd )

/**end_proto**/

{

     U_INT16 i;
     BIT8    ok;

     ok = TRUE;

     for ( i = 0; i< DET_EEPROM_SIZE; i++ )
     {
          if ( i == CHECKSUM ) continue;

          EEPROM_Write_Address = i;
          EEPROM_Write_Data    = Det_EEPROM_Default [ i ].value;
          ok &= WriteEeprom ( module, i, Det_EEPROM_Default[ i ].value );
     }

     WriteDetPIDs ( module, (EEPROM_DET_TYPE)type );


     type = type | ((U_INT16)DET_MODULE << 8);




     EEPROM_Write_Address = TYPE;
     EEPROM_Write_Data    = type;
     ok &= WriteEeprom ( module, EEPROM_Write_Address, EEPROM_Write_Data );

     EEPROM_Write_Address = PS_RANGE+0;

     switch ( type    )
     {
        case  (U_INT16)EPC_TCD :
        case  (U_INT16)EPC_ECD :
        case  (U_INT16)EPC_uECD :
        case  (U_INT16)EPC_uECD2 :
        case  (U_INT16)EPC_LDID :
                 EEPROM_Write_Data    = INVALID_PS_RANGE;
                 break;

       default:
                 EEPROM_Write_Data    = range;
     }

     ok &= WriteEeprom ( module, EEPROM_Write_Address, EEPROM_Write_Data );

     EEPROM_Write_Address = P_SCALING+0;
     EEPROM_Write_Data    = scale;
     ok &= WriteEeprom ( module, EEPROM_Write_Address, EEPROM_Write_Data );

     EEPROM_Write_Address = PS_RANGE+1;
     EEPROM_Write_Data    = range;
     ok &= WriteEeprom ( module, EEPROM_Write_Address, EEPROM_Write_Data );

     EEPROM_Write_Address = P_SCALING+1;
     EEPROM_Write_Data    = scale;
     ok &= WriteEeprom ( module, EEPROM_Write_Address, EEPROM_Write_Data );

     EEPROM_Write_Address = PS_RANGE+2;
     EEPROM_Write_Data    = range;
     ok &= WriteEeprom ( module, EEPROM_Write_Address, EEPROM_Write_Data );

     EEPROM_Write_Address = P_SCALING+2;
     EEPROM_Write_Data    = scale;
     ok &= WriteEeprom ( module, EEPROM_Write_Address, EEPROM_Write_Data );

     ok &= WriteEeprom( module, BUILD_DATE, bd );
     ok &= WriteEeprom( module, SERIAL_NO_HIGH, snh );
     ok &= WriteEeprom( module, SERIAL_NO_LOW,  snl );

     WriteDetMaxFlows( module );
     WriteDetMinFlows( module );

     return ok;

}



static const UPDATE_TABLE_ENTRY  D_0107_Update[] = {

  { SAVE_WORD, 0x02,   0,      0 },       /* save the module type word */
  { INIT_WORD, 0xffff, 0x02,   0 },       /* scribble module type in case of failure */


  { INIT_WORD, 0x2ccc, 0x06,   0 },      /* a delta volts term for the thermistor */
  { INIT_WORD, 0x0780, 0x07,   0 },      /* a delta temp term for the thermistor */

  { COPY_BLOCK,0x3f,   0x42,   54},      /*  all the temp comp stuff  */

  { COPY_ROW,  0x3c,   0x7d,   0 },      /* save the offset temp gains  */

  { COPY_BLOCK,0x21,   0x27,   27},      /* user calib and user pids */

  { INIT_ROW,  0x0000, 0x24,   0 },      /* dSpan_dT */

  { COPY_ROW,  0x1e,   0x21,   0 },      /* span */

  { COPY_ROW,  0x7d,   0x1e,   0 },      /* previously saved dOffset_dT */

  { INIT_WORD, 0x0107, 0x01,   0 },      /* update the version field */

  { RESTORE_WORD, 0,   0x02,   0 },      /* return the module type word */

  { END,       0,      0,      0 } };


/**begin_proto**/

void UpdateDetectorEeprom0107( pDETECTOR_STATUS status )

/**end_proto**/
{

   UpdateEeprom( status->Module_Number, (pUPDATE_TABLE)D_0107_Update );

}



static const UPDATE_TABLE_ENTRY  INIT_FID_PID_TABLE[] = {



 { INIT_PID,  0x004f, FACT_CH_3_N2_I_GAIN,      3},
 { INIT_PID,  0x003e, FACT_CH_3_N2_P_GAIN,      3},
 { INIT_PID,  0x003a, FACT_CH_3_N2_D_GAIN,      3},
 { INIT_PID,  0xffff, FACT_CH_3_N2_NL_GAIN,     3},

 { INIT_PID,  0x0031, FACT_CH_1_H2_I_GAIN,      1},
 { INIT_PID,  0x0040, FACT_CH_1_H2_P_GAIN,      1},
 { INIT_PID,  0x0036, FACT_CH_1_H2_D_GAIN,      1},
 { INIT_PID,  0xffff, FACT_CH_1_H2_NL_GAIN,     1},





 { INIT_PID,  0x004f, FACT_CH_3_He_I_GAIN,      3},
 { INIT_PID,  0x0041, FACT_CH_3_He_P_GAIN,      3},
 { INIT_PID,  0x003c, FACT_CH_3_He_D_GAIN,      3},
 { INIT_PID,  0xffff, FACT_CH_3_He_NL_GAIN,     3},








 { INIT_PID,  0x0052, FACT_CH_2_Air_I_GAIN,     2},
 { INIT_PID,  0x002d, FACT_CH_2_Air_P_GAIN,     2},
 { INIT_PID,  0x001d, FACT_CH_2_Air_D_GAIN,     2},
 { INIT_PID,  0xffff, FACT_CH_2_Air_NL_GAIN,    2},




 { INIT_PID,  0x004f, FACT_CH_3_Ar_I_GAIN,      3},
 { INIT_PID,  0x003e, FACT_CH_3_Ar_P_GAIN,      3},
 { INIT_PID,  0x003a, FACT_CH_3_Ar_D_GAIN,      3},
 { INIT_PID,  0xffff, FACT_CH_3_Ar_NL_GAIN,     3},

 { INIT_WORD, 0x0000, USER_CH_1_N2_I_GAIN,      0},
 { INIT_WORD, 0x0000, USER_CH_1_N2_P_GAIN,      0},
 { INIT_WORD, 0x0000, USER_CH_1_N2_D_GAIN,      0},
 { INIT_WORD, 0xffff, USER_CH_1_N2_NL_GAIN,     0},

 { INIT_WORD, 0x0000, USER_CH_2_N2_I_GAIN,      0},
 { INIT_WORD, 0x0000, USER_CH_2_N2_P_GAIN,      0},
 { INIT_WORD, 0x0000, USER_CH_2_N2_D_GAIN,      0},
 { INIT_WORD, 0xffff, USER_CH_2_N2_NL_GAIN,     0},

 { INIT_WORD, 0x0000, USER_CH_3_N2_I_GAIN,      0},
 { INIT_WORD, 0x0000, USER_CH_3_N2_P_GAIN,      0},
 { INIT_WORD, 0x0000, USER_CH_3_N2_D_GAIN,      0},
 { INIT_WORD, 0xffff, USER_CH_3_N2_NL_GAIN,     0},

 { INIT_WORD, 0x0000, USER_CH_1_H2_I_GAIN,      0},
 { INIT_WORD, 0x0000, USER_CH_1_H2_P_GAIN,      0},
 { INIT_WORD, 0x0000, USER_CH_1_H2_D_GAIN,      0},
 { INIT_WORD, 0xffff, USER_CH_1_H2_NL_GAIN,     0},

 { INIT_WORD, 0x0000, USER_CH_2_H2_I_GAIN,      0},
 { INIT_WORD, 0x0000, USER_CH_2_H2_P_GAIN,      0},
 { INIT_WORD, 0x0000, USER_CH_2_H2_D_GAIN,      0},
 { INIT_WORD, 0xffff, USER_CH_2_H2_NL_GAIN,     0},

 { INIT_WORD, 0x0000, USER_CH_3_H2_I_GAIN,      0},
 { INIT_WORD, 0x0000, USER_CH_3_H2_P_GAIN,      0},
 { INIT_WORD, 0x0000, USER_CH_3_H2_D_GAIN,      0},
 { INIT_WORD, 0xffff, USER_CH_3_H2_NL_GAIN,     0},

 { INIT_WORD, 0x0000, USER_CH_1_He_I_GAIN,      0},
 { INIT_WORD, 0x0000, USER_CH_1_He_P_GAIN,      0},
 { INIT_WORD, 0x0000, USER_CH_1_He_D_GAIN,      0},
 { INIT_WORD, 0xffff, USER_CH_1_He_NL_GAIN,     0},

 { INIT_WORD, 0x0000, USER_CH_2_He_I_GAIN,      0},
 { INIT_WORD, 0x0000, USER_CH_2_He_P_GAIN,      0},
 { INIT_WORD, 0x0000, USER_CH_2_He_D_GAIN,      0},
 { INIT_WORD, 0xffff, USER_CH_2_He_NL_GAIN,     0},

 { INIT_WORD, 0x0000, USER_CH_3_He_I_GAIN,      0},
 { INIT_WORD, 0x0000, USER_CH_3_He_P_GAIN,      0},
 { INIT_WORD, 0x0000, USER_CH_3_He_D_GAIN,      0},
 { INIT_WORD, 0xffff, USER_CH_3_He_NL_GAIN,     0},

 { INIT_WORD, 0x0000, USER_CH_1_ArMe_I_GAIN,    0},
 { INIT_WORD, 0x0000, USER_CH_1_ArMe_P_GAIN,    0},
 { INIT_WORD, 0x0000, USER_CH_1_ArMe_D_GAIN,    0},
 { INIT_WORD, 0xffff, USER_CH_1_ArMe_NL_GAIN,   0},

 { INIT_WORD, 0x0000, USER_CH_2_ArMe_I_GAIN,    0},
 { INIT_WORD, 0x0000, USER_CH_2_ArMe_P_GAIN,    0},
 { INIT_WORD, 0x0000, USER_CH_2_ArMe_D_GAIN,    0},
 { INIT_WORD, 0xffff, USER_CH_2_ArMe_NL_GAIN,   0},

 { INIT_WORD, 0x0000, USER_CH_3_ArMe_I_GAIN,    0},
 { INIT_WORD, 0x0000, USER_CH_3_ArMe_P_GAIN,    0},
 { INIT_WORD, 0x0000, USER_CH_3_ArMe_D_GAIN,    0},
 { INIT_WORD, 0xffff, USER_CH_3_ArMe_NL_GAIN,   0},

 { INIT_WORD, 0x0000, USER_CH_2_O2_I_GAIN,      0},
 { INIT_WORD, 0x0000, USER_CH_2_O2_P_GAIN,      0},
 { INIT_WORD, 0x0000, USER_CH_2_O2_D_GAIN,      0},
 { INIT_WORD, 0xffff, USER_CH_2_O2_NL_GAIN,     0},

 { INIT_WORD, 0x0000, USER_CH_2_Air_I_GAIN,     0},
 { INIT_WORD, 0x0000, USER_CH_2_Air_P_GAIN,     0},
 { INIT_WORD, 0x0000, USER_CH_2_Air_D_GAIN,     0},
 { INIT_WORD, 0xffff, USER_CH_2_Air_NL_GAIN,    0},

 { INIT_WORD, 0x0000, USER_CH_2_Ar_I_GAIN,      0},
 { INIT_WORD, 0x0000, USER_CH_2_Ar_P_GAIN,      0},
 { INIT_WORD, 0x0000, USER_CH_2_Ar_D_GAIN,      0},
 { INIT_WORD, 0xffff, USER_CH_2_Ar_NL_GAIN,     0},

 { INIT_WORD, 0x0000, USER_CH_3_Ar_I_GAIN,      0},
 { INIT_WORD, 0x0000, USER_CH_3_Ar_P_GAIN,      0},
 { INIT_WORD, 0x0000, USER_CH_3_Ar_D_GAIN,      0},
 { INIT_WORD, 0xffff, USER_CH_3_Ar_NL_GAIN,     0},

 { END,         0,      0,      0}  };


static const UPDATE_TABLE_ENTRY  INIT_TCD_PID_TABLE[] = {


 { INIT_PID,  0x0104, FACT_CH_2_N2_I_GAIN,      2},
 { INIT_PID,  0x017c, FACT_CH_2_N2_P_GAIN,      2},
 { INIT_PID,  0x0182, FACT_CH_2_N2_D_GAIN,      2},
 { INIT_PID,  0xffff, FACT_CH_2_N2_NL_GAIN,     2},

 { INIT_PID,  0x00f4, FACT_CH_3_N2_I_GAIN,      3},
 { INIT_PID,  0x03d0, FACT_CH_3_N2_P_GAIN,      3},
 { INIT_PID,  0x03e2, FACT_CH_3_N2_D_GAIN,      3},
 { INIT_PID,  0xffff, FACT_CH_3_N2_NL_GAIN,     3},


 { INIT_PID,  0x0095, FACT_CH_2_H2_I_GAIN,      2},
 { INIT_PID,  0x00da, FACT_CH_2_H2_P_GAIN,      2},
 { INIT_PID,  0x00ce, FACT_CH_2_H2_D_GAIN,      2},
 { INIT_PID,  0xffff, FACT_CH_2_H2_NL_GAIN,     2},

 { INIT_PID,  0x007b, FACT_CH_3_H2_I_GAIN,      3},
 { INIT_PID,  0x01ef, FACT_CH_3_H2_P_GAIN,      3},
 { INIT_PID,  0x01d0, FACT_CH_3_H2_D_GAIN,      3},
 { INIT_PID,  0xffff, FACT_CH_3_H2_NL_GAIN,     3},


 { INIT_PID,  0x00bf, FACT_CH_2_He_I_GAIN,      2},
 { INIT_PID,  0x00fe, FACT_CH_2_He_P_GAIN,      2},
 { INIT_PID,  0x00ee, FACT_CH_2_He_D_GAIN,      2},
 { INIT_PID,  0xffff, FACT_CH_2_He_NL_GAIN,     2},

 { INIT_PID,  0x0087, FACT_CH_3_He_I_GAIN,      3},
 { INIT_PID,  0x033e, FACT_CH_3_He_P_GAIN,      3},
 { INIT_PID,  0x031c, FACT_CH_3_He_D_GAIN,      3},
 { INIT_PID,  0xffff, FACT_CH_3_He_NL_GAIN,     3},











 { INIT_PID,  0x0104, FACT_CH_2_Ar_I_GAIN,      2},
 { INIT_PID,  0x017c, FACT_CH_2_Ar_P_GAIN,      2},
 { INIT_PID,  0x0182, FACT_CH_2_Ar_D_GAIN,      2},
 { INIT_PID,  0xffff, FACT_CH_2_Ar_NL_GAIN,     2},

 { INIT_PID,  0x00f4, FACT_CH_3_Ar_I_GAIN,      3},
 { INIT_PID,  0x03d0, FACT_CH_3_Ar_P_GAIN,      3},
 { INIT_PID,  0x03e2, FACT_CH_3_Ar_D_GAIN,      3},
 { INIT_PID,  0xffff, FACT_CH_3_Ar_NL_GAIN,     3},

 { INIT_WORD, 0x0000, USER_CH_1_N2_I_GAIN,      0},
 { INIT_WORD, 0x0000, USER_CH_1_N2_P_GAIN,      0},
 { INIT_WORD, 0x0000, USER_CH_1_N2_D_GAIN,      0},
 { INIT_WORD, 0xffff, USER_CH_1_N2_NL_GAIN,     0},

 { INIT_WORD, 0x0000, USER_CH_2_N2_I_GAIN,      0},
 { INIT_WORD, 0x0000, USER_CH_2_N2_P_GAIN,      0},
 { INIT_WORD, 0x0000, USER_CH_2_N2_D_GAIN,      0},
 { INIT_WORD, 0xffff, USER_CH_2_N2_NL_GAIN,     0},

 { INIT_WORD, 0x0000, USER_CH_3_N2_I_GAIN,      0},
 { INIT_WORD, 0x0000, USER_CH_3_N2_P_GAIN,      0},
 { INIT_WORD, 0x0000, USER_CH_3_N2_D_GAIN,      0},
 { INIT_WORD, 0xffff, USER_CH_3_N2_NL_GAIN,     0},

 { INIT_WORD, 0x0000, USER_CH_1_H2_I_GAIN,      0},
 { INIT_WORD, 0x0000, USER_CH_1_H2_P_GAIN,      0},
 { INIT_WORD, 0x0000, USER_CH_1_H2_D_GAIN,      0},
 { INIT_WORD, 0xffff, USER_CH_1_H2_NL_GAIN,     0},

 { INIT_WORD, 0x0000, USER_CH_2_H2_I_GAIN,      0},
 { INIT_WORD, 0x0000, USER_CH_2_H2_P_GAIN,      0},
 { INIT_WORD, 0x0000, USER_CH_2_H2_D_GAIN,      0},
 { INIT_WORD, 0xffff, USER_CH_2_H2_NL_GAIN,     0},

 { INIT_WORD, 0x0000, USER_CH_3_H2_I_GAIN,      0},
 { INIT_WORD, 0x0000, USER_CH_3_H2_P_GAIN,      0},
 { INIT_WORD, 0x0000, USER_CH_3_H2_D_GAIN,      0},
 { INIT_WORD, 0xffff, USER_CH_3_H2_NL_GAIN,     0},

 { INIT_WORD, 0x0000, USER_CH_1_He_I_GAIN,      0},
 { INIT_WORD, 0x0000, USER_CH_1_He_P_GAIN,      0},
 { INIT_WORD, 0x0000, USER_CH_1_He_D_GAIN,      0},
 { INIT_WORD, 0xffff, USER_CH_1_He_NL_GAIN,     0},

 { INIT_WORD, 0x0000, USER_CH_2_He_I_GAIN,      0},
 { INIT_WORD, 0x0000, USER_CH_2_He_P_GAIN,      0},
 { INIT_WORD, 0x0000, USER_CH_2_He_D_GAIN,      0},
 { INIT_WORD, 0xffff, USER_CH_2_He_NL_GAIN,     0},

 { INIT_WORD, 0x0000, USER_CH_3_He_I_GAIN,      0},
 { INIT_WORD, 0x0000, USER_CH_3_He_P_GAIN,      0},
 { INIT_WORD, 0x0000, USER_CH_3_He_D_GAIN,      0},
 { INIT_WORD, 0xffff, USER_CH_3_He_NL_GAIN,     0},

 { INIT_WORD, 0x0000, USER_CH_1_ArMe_I_GAIN,    0},
 { INIT_WORD, 0x0000, USER_CH_1_ArMe_P_GAIN,    0},
 { INIT_WORD, 0x0000, USER_CH_1_ArMe_D_GAIN,    0},
 { INIT_WORD, 0xffff, USER_CH_1_ArMe_NL_GAIN,   0},

 { INIT_WORD, 0x0000, USER_CH_2_ArMe_I_GAIN,    0},
 { INIT_WORD, 0x0000, USER_CH_2_ArMe_P_GAIN,    0},
 { INIT_WORD, 0x0000, USER_CH_2_ArMe_D_GAIN,    0},
 { INIT_WORD, 0xffff, USER_CH_2_ArMe_NL_GAIN,   0},

 { INIT_WORD, 0x0000, USER_CH_3_ArMe_I_GAIN,    0},
 { INIT_WORD, 0x0000, USER_CH_3_ArMe_P_GAIN,    0},
 { INIT_WORD, 0x0000, USER_CH_3_ArMe_D_GAIN,    0},
 { INIT_WORD, 0xffff, USER_CH_3_ArMe_NL_GAIN,   0},

 { INIT_WORD, 0x0000, USER_CH_2_O2_I_GAIN,      0},
 { INIT_WORD, 0x0000, USER_CH_2_O2_P_GAIN,      0},
 { INIT_WORD, 0x0000, USER_CH_2_O2_D_GAIN,      0},
 { INIT_WORD, 0xffff, USER_CH_2_O2_NL_GAIN,     0},

 { INIT_WORD, 0x0000, USER_CH_2_Air_I_GAIN,     0},
 { INIT_WORD, 0x0000, USER_CH_2_Air_P_GAIN,     0},
 { INIT_WORD, 0x0000, USER_CH_2_Air_D_GAIN,     0},
 { INIT_WORD, 0xffff, USER_CH_2_Air_NL_GAIN,    0},

 { INIT_WORD, 0x0000, USER_CH_2_Ar_I_GAIN,      0},
 { INIT_WORD, 0x0000, USER_CH_2_Ar_P_GAIN,      0},
 { INIT_WORD, 0x0000, USER_CH_2_Ar_D_GAIN,      0},
 { INIT_WORD, 0xffff, USER_CH_2_Ar_NL_GAIN,     0},

 { INIT_WORD, 0x0000, USER_CH_3_Ar_I_GAIN,      0},
 { INIT_WORD, 0x0000, USER_CH_3_Ar_P_GAIN,      0},
 { INIT_WORD, 0x0000, USER_CH_3_Ar_D_GAIN,      0},
 { INIT_WORD, 0xffff, USER_CH_3_Ar_NL_GAIN,     0},

 { END,         0,      0,      0}  };


static const UPDATE_TABLE_ENTRY  INIT_NPD_PID_TABLE[] = {



 { INIT_PID,  0x004f, FACT_CH_3_N2_I_GAIN,      3},
 { INIT_PID,  0x003e, FACT_CH_3_N2_P_GAIN,      3},
 { INIT_PID,  0x003a, FACT_CH_3_N2_D_GAIN,      3},
 { INIT_PID,  0xffff, FACT_CH_3_N2_NL_GAIN,     3},

 { INIT_PID,  0x0025, FACT_CH_1_H2_I_GAIN,      1},
 { INIT_PID,  0x0040, FACT_CH_1_H2_P_GAIN,      1},
 { INIT_PID,  0x005d, FACT_CH_1_H2_D_GAIN,      1},
 { INIT_PID,  0xffff, FACT_CH_1_H2_NL_GAIN,     1},





 { INIT_PID,  0x004f, FACT_CH_3_He_I_GAIN,      3},
 { INIT_PID,  0x0041, FACT_CH_3_He_P_GAIN,      3},
 { INIT_PID,  0x003c, FACT_CH_3_He_D_GAIN,      3},
 { INIT_PID,  0xffff, FACT_CH_3_He_NL_GAIN,     3},








 { INIT_PID,  0x004b, FACT_CH_2_Air_I_GAIN,     2},
 { INIT_PID,  0x0029, FACT_CH_2_Air_P_GAIN,     2},
 { INIT_PID,  0x001f, FACT_CH_2_Air_D_GAIN,     2},
 { INIT_PID,  0xffff, FACT_CH_2_Air_NL_GAIN,    2},




 { INIT_PID,  0x040b, FACT_CH_3_Ar_I_GAIN,      3},
 { INIT_PID,  0x0076, FACT_CH_3_Ar_P_GAIN,      3},
 { INIT_PID,  0x006b, FACT_CH_3_Ar_D_GAIN,      3},
 { INIT_PID,  0xffff, FACT_CH_3_Ar_NL_GAIN,     3},

 { INIT_WORD, 0x0000, USER_CH_1_N2_I_GAIN,      0},
 { INIT_WORD, 0x0000, USER_CH_1_N2_P_GAIN,      0},
 { INIT_WORD, 0x0000, USER_CH_1_N2_D_GAIN,      0},
 { INIT_WORD, 0xffff, USER_CH_1_N2_NL_GAIN,     0},

 { INIT_WORD, 0x0000, USER_CH_2_N2_I_GAIN,      0},
 { INIT_WORD, 0x0000, USER_CH_2_N2_P_GAIN,      0},
 { INIT_WORD, 0x0000, USER_CH_2_N2_D_GAIN,      0},
 { INIT_WORD, 0xffff, USER_CH_2_N2_NL_GAIN,     0},

 { INIT_WORD, 0x0000, USER_CH_3_N2_I_GAIN,      0},
 { INIT_WORD, 0x0000, USER_CH_3_N2_P_GAIN,      0},
 { INIT_WORD, 0x0000, USER_CH_3_N2_D_GAIN,      0},
 { INIT_WORD, 0xffff, USER_CH_3_N2_NL_GAIN,     0},

 { INIT_WORD, 0x0000, USER_CH_1_H2_I_GAIN,      0},
 { INIT_WORD, 0x0000, USER_CH_1_H2_P_GAIN,      0},
 { INIT_WORD, 0x0000, USER_CH_1_H2_D_GAIN,      0},
 { INIT_WORD, 0xffff, USER_CH_1_H2_NL_GAIN,     0},

 { INIT_WORD, 0x0000, USER_CH_2_H2_I_GAIN,      0},
 { INIT_WORD, 0x0000, USER_CH_2_H2_P_GAIN,      0},
 { INIT_WORD, 0x0000, USER_CH_2_H2_D_GAIN,      0},
 { INIT_WORD, 0xffff, USER_CH_2_H2_NL_GAIN,     0},

 { INIT_WORD, 0x0000, USER_CH_3_H2_I_GAIN,      0},
 { INIT_WORD, 0x0000, USER_CH_3_H2_P_GAIN,      0},
 { INIT_WORD, 0x0000, USER_CH_3_H2_D_GAIN,      0},
 { INIT_WORD, 0xffff, USER_CH_3_H2_NL_GAIN,     0},

 { INIT_WORD, 0x0000, USER_CH_1_He_I_GAIN,      0},
 { INIT_WORD, 0x0000, USER_CH_1_He_P_GAIN,      0},
 { INIT_WORD, 0x0000, USER_CH_1_He_D_GAIN,      0},
 { INIT_WORD, 0xffff, USER_CH_1_He_NL_GAIN,     0},

 { INIT_WORD, 0x0000, USER_CH_2_He_I_GAIN,      0},
 { INIT_WORD, 0x0000, USER_CH_2_He_P_GAIN,      0},
 { INIT_WORD, 0x0000, USER_CH_2_He_D_GAIN,      0},
 { INIT_WORD, 0xffff, USER_CH_2_He_NL_GAIN,     0},

 { INIT_WORD, 0x0000, USER_CH_3_He_I_GAIN,      0},
 { INIT_WORD, 0x0000, USER_CH_3_He_P_GAIN,      0},
 { INIT_WORD, 0x0000, USER_CH_3_He_D_GAIN,      0},
 { INIT_WORD, 0xffff, USER_CH_3_He_NL_GAIN,     0},

 { INIT_WORD, 0x0000, USER_CH_1_ArMe_I_GAIN,    0},
 { INIT_WORD, 0x0000, USER_CH_1_ArMe_P_GAIN,    0},
 { INIT_WORD, 0x0000, USER_CH_1_ArMe_D_GAIN,    0},
 { INIT_WORD, 0xffff, USER_CH_1_ArMe_NL_GAIN,   0},

 { INIT_WORD, 0x0000, USER_CH_2_ArMe_I_GAIN,    0},
 { INIT_WORD, 0x0000, USER_CH_2_ArMe_P_GAIN,    0},
 { INIT_WORD, 0x0000, USER_CH_2_ArMe_D_GAIN,    0},
 { INIT_WORD, 0xffff, USER_CH_2_ArMe_NL_GAIN,   0},

 { INIT_WORD, 0x0000, USER_CH_3_ArMe_I_GAIN,    0},
 { INIT_WORD, 0x0000, USER_CH_3_ArMe_P_GAIN,    0},
 { INIT_WORD, 0x0000, USER_CH_3_ArMe_D_GAIN,    0},
 { INIT_WORD, 0xffff, USER_CH_3_ArMe_NL_GAIN,   0},

 { INIT_WORD, 0x0000, USER_CH_2_O2_I_GAIN,      0},
 { INIT_WORD, 0x0000, USER_CH_2_O2_P_GAIN,      0},
 { INIT_WORD, 0x0000, USER_CH_2_O2_D_GAIN,      0},
 { INIT_WORD, 0xffff, USER_CH_2_O2_NL_GAIN,     0},

 { INIT_WORD, 0x0000, USER_CH_2_Air_I_GAIN,     0},
 { INIT_WORD, 0x0000, USER_CH_2_Air_P_GAIN,     0},
 { INIT_WORD, 0x0000, USER_CH_2_Air_D_GAIN,     0},
 { INIT_WORD, 0xffff, USER_CH_2_Air_NL_GAIN,    0},

 { INIT_WORD, 0x0000, USER_CH_2_Ar_I_GAIN,      0},
 { INIT_WORD, 0x0000, USER_CH_2_Ar_P_GAIN,      0},
 { INIT_WORD, 0x0000, USER_CH_2_Ar_D_GAIN,      0},
 { INIT_WORD, 0xffff, USER_CH_2_Ar_NL_GAIN,     0},

 { INIT_WORD, 0x0000, USER_CH_3_Ar_I_GAIN,      0},
 { INIT_WORD, 0x0000, USER_CH_3_Ar_P_GAIN,      0},
 { INIT_WORD, 0x0000, USER_CH_3_Ar_D_GAIN,      0},
 { INIT_WORD, 0xffff, USER_CH_3_Ar_NL_GAIN,     0},

 { END,         0,      0,      0}  };


static const UPDATE_TABLE_ENTRY  INIT_ECD_PID_TABLE[] = {


 { INIT_PID,  0x0045, FACT_CH_2_N2_I_GAIN,      2},
 { INIT_PID,  0x0059, FACT_CH_2_N2_P_GAIN,      2},
 { INIT_PID,  0x0056, FACT_CH_2_N2_D_GAIN,      2},
 { INIT_PID,  0xffff, FACT_CH_2_N2_NL_GAIN,     2},

 { INIT_PID,  0x0033, FACT_CH_3_N2_I_GAIN,      3},
 { INIT_PID,  0x002b, FACT_CH_3_N2_P_GAIN,      3},
 { INIT_PID,  0x0020, FACT_CH_3_N2_D_GAIN,      3},
 { INIT_PID,  0xffff, FACT_CH_3_N2_NL_GAIN,     3},





 { INIT_PID,  0x0050, FACT_CH_2_He_I_GAIN,      2},
 { INIT_PID,  0x0070, FACT_CH_2_He_P_GAIN,      2},
 { INIT_PID,  0x0061, FACT_CH_2_He_D_GAIN,      2},
 { INIT_PID,  0xffff, FACT_CH_2_He_NL_GAIN,     2},

 { INIT_PID,  0x0021, FACT_CH_3_He_I_GAIN,      3},
 { INIT_PID,  0x0021, FACT_CH_3_He_P_GAIN,      3},
 { INIT_PID,  0x001b, FACT_CH_3_He_D_GAIN,      3},
 { INIT_PID,  0xffff, FACT_CH_3_He_NL_GAIN,     3},


 { INIT_PID,  0x0054, FACT_CH_2_ArMe_I_GAIN,    2},
 { INIT_PID,  0x005c, FACT_CH_2_ArMe_P_GAIN,    2},
 { INIT_PID,  0x0053, FACT_CH_2_ArMe_D_GAIN,    2},
 { INIT_PID,  0xffff, FACT_CH_2_ArMe_NL_GAIN,   2},

 { INIT_PID,  0x0032, FACT_CH_3_ArMe_I_GAIN,    3},
 { INIT_PID,  0x0029, FACT_CH_3_ArMe_P_GAIN,    3},
 { INIT_PID,  0x001d, FACT_CH_3_ArMe_D_GAIN,    3},
 { INIT_PID,  0xffff, FACT_CH_3_ArMe_NL_GAIN,   3},










 { INIT_WORD, 0x0000, USER_CH_1_N2_I_GAIN,      0},
 { INIT_WORD, 0x0000, USER_CH_1_N2_P_GAIN,      0},
 { INIT_WORD, 0x0000, USER_CH_1_N2_D_GAIN,      0},
 { INIT_WORD, 0xffff, USER_CH_1_N2_NL_GAIN,     0},

 { INIT_WORD, 0x0000, USER_CH_2_N2_I_GAIN,      0},
 { INIT_WORD, 0x0000, USER_CH_2_N2_P_GAIN,      0},
 { INIT_WORD, 0x0000, USER_CH_2_N2_D_GAIN,      0},
 { INIT_WORD, 0xffff, USER_CH_2_N2_NL_GAIN,     0},

 { INIT_WORD, 0x0000, USER_CH_3_N2_I_GAIN,      0},
 { INIT_WORD, 0x0000, USER_CH_3_N2_P_GAIN,      0},
 { INIT_WORD, 0x0000, USER_CH_3_N2_D_GAIN,      0},
 { INIT_WORD, 0xffff, USER_CH_3_N2_NL_GAIN,     0},

 { INIT_WORD, 0x0000, USER_CH_1_H2_I_GAIN,      0},
 { INIT_WORD, 0x0000, USER_CH_1_H2_P_GAIN,      0},
 { INIT_WORD, 0x0000, USER_CH_1_H2_D_GAIN,      0},
 { INIT_WORD, 0xffff, USER_CH_1_H2_NL_GAIN,     0},

 { INIT_WORD, 0x0000, USER_CH_2_H2_I_GAIN,      0},
 { INIT_WORD, 0x0000, USER_CH_2_H2_P_GAIN,      0},
 { INIT_WORD, 0x0000, USER_CH_2_H2_D_GAIN,      0},
 { INIT_WORD, 0xffff, USER_CH_2_H2_NL_GAIN,     0},

 { INIT_WORD, 0x0000, USER_CH_3_H2_I_GAIN,      0},
 { INIT_WORD, 0x0000, USER_CH_3_H2_P_GAIN,      0},
 { INIT_WORD, 0x0000, USER_CH_3_H2_D_GAIN,      0},
 { INIT_WORD, 0xffff, USER_CH_3_H2_NL_GAIN,     0},

 { INIT_WORD, 0x0000, USER_CH_1_He_I_GAIN,      0},
 { INIT_WORD, 0x0000, USER_CH_1_He_P_GAIN,      0},
 { INIT_WORD, 0x0000, USER_CH_1_He_D_GAIN,      0},
 { INIT_WORD, 0xffff, USER_CH_1_He_NL_GAIN,     0},

 { INIT_WORD, 0x0000, USER_CH_2_He_I_GAIN,      0},
 { INIT_WORD, 0x0000, USER_CH_2_He_P_GAIN,      0},
 { INIT_WORD, 0x0000, USER_CH_2_He_D_GAIN,      0},
 { INIT_WORD, 0xffff, USER_CH_2_He_NL_GAIN,     0},

 { INIT_WORD, 0x0000, USER_CH_3_He_I_GAIN,      0},
 { INIT_WORD, 0x0000, USER_CH_3_He_P_GAIN,      0},
 { INIT_WORD, 0x0000, USER_CH_3_He_D_GAIN,      0},
 { INIT_WORD, 0xffff, USER_CH_3_He_NL_GAIN,     0},

 { INIT_WORD, 0x0000, USER_CH_1_ArMe_I_GAIN,    0},
 { INIT_WORD, 0x0000, USER_CH_1_ArMe_P_GAIN,    0},
 { INIT_WORD, 0x0000, USER_CH_1_ArMe_D_GAIN,    0},
 { INIT_WORD, 0xffff, USER_CH_1_ArMe_NL_GAIN,   0},

 { INIT_WORD, 0x0000, USER_CH_2_ArMe_I_GAIN,    0},
 { INIT_WORD, 0x0000, USER_CH_2_ArMe_P_GAIN,    0},
 { INIT_WORD, 0x0000, USER_CH_2_ArMe_D_GAIN,    0},
 { INIT_WORD, 0xffff, USER_CH_2_ArMe_NL_GAIN,   0},

 { INIT_WORD, 0x0000, USER_CH_3_ArMe_I_GAIN,    0},
 { INIT_WORD, 0x0000, USER_CH_3_ArMe_P_GAIN,    0},
 { INIT_WORD, 0x0000, USER_CH_3_ArMe_D_GAIN,    0},
 { INIT_WORD, 0xffff, USER_CH_3_ArMe_NL_GAIN,   0},

 { INIT_WORD, 0x0000, USER_CH_2_O2_I_GAIN,      0},
 { INIT_WORD, 0x0000, USER_CH_2_O2_P_GAIN,      0},
 { INIT_WORD, 0x0000, USER_CH_2_O2_D_GAIN,      0},
 { INIT_WORD, 0xffff, USER_CH_2_O2_NL_GAIN,     0},

 { INIT_WORD, 0x0000, USER_CH_2_Air_I_GAIN,     0},
 { INIT_WORD, 0x0000, USER_CH_2_Air_P_GAIN,     0},
 { INIT_WORD, 0x0000, USER_CH_2_Air_D_GAIN,     0},
 { INIT_WORD, 0xffff, USER_CH_2_Air_NL_GAIN,    0},

 { INIT_WORD, 0x0000, USER_CH_2_Ar_I_GAIN,      0},
 { INIT_WORD, 0x0000, USER_CH_2_Ar_P_GAIN,      0},
 { INIT_WORD, 0x0000, USER_CH_2_Ar_D_GAIN,      0},
 { INIT_WORD, 0xffff, USER_CH_2_Ar_NL_GAIN,     0},

 { INIT_WORD, 0x0000, USER_CH_3_Ar_I_GAIN,      0},
 { INIT_WORD, 0x0000, USER_CH_3_Ar_P_GAIN,      0},
 { INIT_WORD, 0x0000, USER_CH_3_Ar_D_GAIN,      0},
 { INIT_WORD, 0xffff, USER_CH_3_Ar_NL_GAIN,     0},

 { END,         0,      0,      0}  };


static const UPDATE_TABLE_ENTRY  INIT_FPD_PID_TABLE[] = {



 { INIT_PID,  0x0033, FACT_CH_3_N2_I_GAIN,      3},
 { INIT_PID,  0x002b, FACT_CH_3_N2_P_GAIN,      3},
 { INIT_PID,  0x0020, FACT_CH_3_N2_D_GAIN,      3},
 { INIT_PID,  0xffff, FACT_CH_3_N2_NL_GAIN,     3},

 { INIT_PID,  0x000C, FACT_CH_1_H2_I_GAIN,      1},
 { INIT_PID,  0x002E, FACT_CH_1_H2_P_GAIN,      1},
 { INIT_PID,  0x0010, FACT_CH_1_H2_D_GAIN,      1},
 { INIT_PID,  0xffff, FACT_CH_1_H2_NL_GAIN,     1},

 { INIT_PID,  0x0021, FACT_CH_3_He_I_GAIN,      3},
 { INIT_PID,  0x0021, FACT_CH_3_He_P_GAIN,      3},
 { INIT_PID,  0x001b, FACT_CH_3_He_D_GAIN,      3},
 { INIT_PID,  0xffff, FACT_CH_3_He_NL_GAIN,     3},

 { INIT_PID,  0x0045, FACT_CH_2_Air_I_GAIN,     2},
 { INIT_PID,  0x0059, FACT_CH_2_Air_P_GAIN,     2},
 { INIT_PID,  0x0056, FACT_CH_2_Air_D_GAIN,     2},
 { INIT_PID,  0xffff, FACT_CH_2_Air_NL_GAIN,    2},




 { INIT_WORD, 0x0000, USER_CH_1_N2_I_GAIN,      0},
 { INIT_WORD, 0x0000, USER_CH_1_N2_P_GAIN,      0},
 { INIT_WORD, 0x0000, USER_CH_1_N2_D_GAIN,      0},
 { INIT_WORD, 0xffff, USER_CH_1_N2_NL_GAIN,     0},

 { INIT_WORD, 0x0000, USER_CH_2_N2_I_GAIN,      0},
 { INIT_WORD, 0x0000, USER_CH_2_N2_P_GAIN,      0},
 { INIT_WORD, 0x0000, USER_CH_2_N2_D_GAIN,      0},
 { INIT_WORD, 0xffff, USER_CH_2_N2_NL_GAIN,     0},

 { INIT_WORD, 0x0000, USER_CH_3_N2_I_GAIN,      0},
 { INIT_WORD, 0x0000, USER_CH_3_N2_P_GAIN,      0},
 { INIT_WORD, 0x0000, USER_CH_3_N2_D_GAIN,      0},
 { INIT_WORD, 0xffff, USER_CH_3_N2_NL_GAIN,     0},

 { INIT_WORD, 0x0000, USER_CH_1_H2_I_GAIN,      0},
 { INIT_WORD, 0x0000, USER_CH_1_H2_P_GAIN,      0},
 { INIT_WORD, 0x0000, USER_CH_1_H2_D_GAIN,      0},
 { INIT_WORD, 0xffff, USER_CH_1_H2_NL_GAIN,     0},

 { INIT_WORD, 0x0000, USER_CH_2_H2_I_GAIN,      0},
 { INIT_WORD, 0x0000, USER_CH_2_H2_P_GAIN,      0},
 { INIT_WORD, 0x0000, USER_CH_2_H2_D_GAIN,      0},
 { INIT_WORD, 0xffff, USER_CH_2_H2_NL_GAIN,     0},

 { INIT_WORD, 0x0000, USER_CH_3_H2_I_GAIN,      0},
 { INIT_WORD, 0x0000, USER_CH_3_H2_P_GAIN,      0},
 { INIT_WORD, 0x0000, USER_CH_3_H2_D_GAIN,      0},
 { INIT_WORD, 0xffff, USER_CH_3_H2_NL_GAIN,     0},

 { INIT_WORD, 0x0000, USER_CH_1_He_I_GAIN,      0},
 { INIT_WORD, 0x0000, USER_CH_1_He_P_GAIN,      0},
 { INIT_WORD, 0x0000, USER_CH_1_He_D_GAIN,      0},
 { INIT_WORD, 0xffff, USER_CH_1_He_NL_GAIN,     0},

 { INIT_WORD, 0x0000, USER_CH_2_He_I_GAIN,      0},
 { INIT_WORD, 0x0000, USER_CH_2_He_P_GAIN,      0},
 { INIT_WORD, 0x0000, USER_CH_2_He_D_GAIN,      0},
 { INIT_WORD, 0xffff, USER_CH_2_He_NL_GAIN,     0},

 { INIT_WORD, 0x0000, USER_CH_3_He_I_GAIN,      0},
 { INIT_WORD, 0x0000, USER_CH_3_He_P_GAIN,      0},
 { INIT_WORD, 0x0000, USER_CH_3_He_D_GAIN,      0},
 { INIT_WORD, 0xffff, USER_CH_3_He_NL_GAIN,     0},

 { INIT_WORD, 0x0000, USER_CH_1_ArMe_I_GAIN,    0},
 { INIT_WORD, 0x0000, USER_CH_1_ArMe_P_GAIN,    0},
 { INIT_WORD, 0x0000, USER_CH_1_ArMe_D_GAIN,    0},
 { INIT_WORD, 0xffff, USER_CH_1_ArMe_NL_GAIN,   0},

 { INIT_WORD, 0x0000, USER_CH_2_ArMe_I_GAIN,    0},
 { INIT_WORD, 0x0000, USER_CH_2_ArMe_P_GAIN,    0},
 { INIT_WORD, 0x0000, USER_CH_2_ArMe_D_GAIN,    0},
 { INIT_WORD, 0xffff, USER_CH_2_ArMe_NL_GAIN,   0},

 { INIT_WORD, 0x0000, USER_CH_3_ArMe_I_GAIN,    0},
 { INIT_WORD, 0x0000, USER_CH_3_ArMe_P_GAIN,    0},
 { INIT_WORD, 0x0000, USER_CH_3_ArMe_D_GAIN,    0},
 { INIT_WORD, 0xffff, USER_CH_3_ArMe_NL_GAIN,   0},

 { INIT_WORD, 0x0000, USER_CH_2_O2_I_GAIN,      0},
 { INIT_WORD, 0x0000, USER_CH_2_O2_P_GAIN,      0},
 { INIT_WORD, 0x0000, USER_CH_2_O2_D_GAIN,      0},
 { INIT_WORD, 0xffff, USER_CH_2_O2_NL_GAIN,     0},

 { INIT_WORD, 0x0000, USER_CH_2_Air_I_GAIN,     0},
 { INIT_WORD, 0x0000, USER_CH_2_Air_P_GAIN,     0},
 { INIT_WORD, 0x0000, USER_CH_2_Air_D_GAIN,     0},
 { INIT_WORD, 0xffff, USER_CH_2_Air_NL_GAIN,    0},

 { INIT_WORD, 0x0000, USER_CH_2_Ar_I_GAIN,      0},
 { INIT_WORD, 0x0000, USER_CH_2_Ar_P_GAIN,      0},
 { INIT_WORD, 0x0000, USER_CH_2_Ar_D_GAIN,      0},
 { INIT_WORD, 0xffff, USER_CH_2_Ar_NL_GAIN,     0},

 { INIT_WORD, 0x0000, USER_CH_3_Ar_I_GAIN,      0},
 { INIT_WORD, 0x0000, USER_CH_3_Ar_P_GAIN,      0},
 { INIT_WORD, 0x0000, USER_CH_3_Ar_D_GAIN,      0},
 { INIT_WORD, 0xffff, USER_CH_3_Ar_NL_GAIN,     0},

 { END,         0,      0,      0}  };

static const UPDATE_TABLE_ENTRY  INIT_uECD_PID_TABLE[] = {


 { INIT_PID,  0x0033, FACT_CH_3_N2_I_GAIN,      3},
 { INIT_PID,  0x002b, FACT_CH_3_N2_P_GAIN,      3},
 { INIT_PID,  0x0020, FACT_CH_3_N2_D_GAIN,      3},
 { INIT_PID,  0xffff, FACT_CH_3_N2_NL_GAIN,     3},

 { INIT_PID,  0xffff, FACT_CH_3_He_I_GAIN,      3},                     /* He no good for ECD; too few valence electrons to capture */
 { INIT_PID,  0xffff, FACT_CH_3_He_P_GAIN,      3},
 { INIT_PID,  0xffff, FACT_CH_3_He_D_GAIN,      3},
 { INIT_PID,  0xffff, FACT_CH_3_He_NL_GAIN,     3},

 { INIT_PID,  0x0032, FACT_CH_3_ArMe_I_GAIN,    3},
 { INIT_PID,  0x0029, FACT_CH_3_ArMe_P_GAIN,    3},
 { INIT_PID,  0x001d, FACT_CH_3_ArMe_D_GAIN,    3},
 { INIT_PID,  0xffff, FACT_CH_3_ArMe_NL_GAIN,   3},







 { INIT_WORD, 0x0000, USER_CH_1_N2_I_GAIN,      0},
 { INIT_WORD, 0x0000, USER_CH_1_N2_P_GAIN,      0},
 { INIT_WORD, 0x0000, USER_CH_1_N2_D_GAIN,      0},
 { INIT_WORD, 0xffff, USER_CH_1_N2_NL_GAIN,     0},

 { INIT_WORD, 0x0000, USER_CH_2_N2_I_GAIN,      0},
 { INIT_WORD, 0x0000, USER_CH_2_N2_P_GAIN,      0},
 { INIT_WORD, 0x0000, USER_CH_2_N2_D_GAIN,      0},
 { INIT_WORD, 0xffff, USER_CH_2_N2_NL_GAIN,     0},

 { INIT_WORD, 0x0000, USER_CH_3_N2_I_GAIN,      0},
 { INIT_WORD, 0x0000, USER_CH_3_N2_P_GAIN,      0},
 { INIT_WORD, 0x0000, USER_CH_3_N2_D_GAIN,      0},
 { INIT_WORD, 0xffff, USER_CH_3_N2_NL_GAIN,     0},

 { INIT_WORD, 0x0000, USER_CH_1_H2_I_GAIN,      0},
 { INIT_WORD, 0x0000, USER_CH_1_H2_P_GAIN,      0},
 { INIT_WORD, 0x0000, USER_CH_1_H2_D_GAIN,      0},
 { INIT_WORD, 0xffff, USER_CH_1_H2_NL_GAIN,     0},

 { INIT_WORD, 0x0000, USER_CH_2_H2_I_GAIN,      0},
 { INIT_WORD, 0x0000, USER_CH_2_H2_P_GAIN,      0},
 { INIT_WORD, 0x0000, USER_CH_2_H2_D_GAIN,      0},
 { INIT_WORD, 0xffff, USER_CH_2_H2_NL_GAIN,     0},

 { INIT_WORD, 0x0000, USER_CH_3_H2_I_GAIN,      0},
 { INIT_WORD, 0x0000, USER_CH_3_H2_P_GAIN,      0},
 { INIT_WORD, 0x0000, USER_CH_3_H2_D_GAIN,      0},
 { INIT_WORD, 0xffff, USER_CH_3_H2_NL_GAIN,     0},

 { INIT_WORD, 0x0000, USER_CH_1_He_I_GAIN,      0},
 { INIT_WORD, 0x0000, USER_CH_1_He_P_GAIN,      0},
 { INIT_WORD, 0x0000, USER_CH_1_He_D_GAIN,      0},
 { INIT_WORD, 0xffff, USER_CH_1_He_NL_GAIN,     0},

 { INIT_WORD, 0x0000, USER_CH_2_He_I_GAIN,      0},
 { INIT_WORD, 0x0000, USER_CH_2_He_P_GAIN,      0},
 { INIT_WORD, 0x0000, USER_CH_2_He_D_GAIN,      0},
 { INIT_WORD, 0xffff, USER_CH_2_He_NL_GAIN,     0},

 { INIT_WORD, 0x0000, USER_CH_3_He_I_GAIN,      0},
 { INIT_WORD, 0x0000, USER_CH_3_He_P_GAIN,      0},
 { INIT_WORD, 0x0000, USER_CH_3_He_D_GAIN,      0},
 { INIT_WORD, 0xffff, USER_CH_3_He_NL_GAIN,     0},

 { INIT_WORD, 0x0000, USER_CH_1_ArMe_I_GAIN,    0},
 { INIT_WORD, 0x0000, USER_CH_1_ArMe_P_GAIN,    0},
 { INIT_WORD, 0x0000, USER_CH_1_ArMe_D_GAIN,    0},
 { INIT_WORD, 0xffff, USER_CH_1_ArMe_NL_GAIN,   0},

 { INIT_WORD, 0x0000, USER_CH_2_ArMe_I_GAIN,    0},
 { INIT_WORD, 0x0000, USER_CH_2_ArMe_P_GAIN,    0},
 { INIT_WORD, 0x0000, USER_CH_2_ArMe_D_GAIN,    0},
 { INIT_WORD, 0xffff, USER_CH_2_ArMe_NL_GAIN,   0},

 { INIT_WORD, 0x0000, USER_CH_3_ArMe_I_GAIN,    0},
 { INIT_WORD, 0x0000, USER_CH_3_ArMe_P_GAIN,    0},
 { INIT_WORD, 0x0000, USER_CH_3_ArMe_D_GAIN,    0},
 { INIT_WORD, 0xffff, USER_CH_3_ArMe_NL_GAIN,   0},

 { INIT_WORD, 0x0000, USER_CH_2_O2_I_GAIN,      0},
 { INIT_WORD, 0x0000, USER_CH_2_O2_P_GAIN,      0},
 { INIT_WORD, 0x0000, USER_CH_2_O2_D_GAIN,      0},
 { INIT_WORD, 0xffff, USER_CH_2_O2_NL_GAIN,     0},

 { INIT_WORD, 0x0000, USER_CH_2_Air_I_GAIN,     0},
 { INIT_WORD, 0x0000, USER_CH_2_Air_P_GAIN,     0},
 { INIT_WORD, 0x0000, USER_CH_2_Air_D_GAIN,     0},
 { INIT_WORD, 0xffff, USER_CH_2_Air_NL_GAIN,    0},

 { INIT_WORD, 0x0000, USER_CH_2_Ar_I_GAIN,      0},
 { INIT_WORD, 0x0000, USER_CH_2_Ar_P_GAIN,      0},
 { INIT_WORD, 0x0000, USER_CH_2_Ar_D_GAIN,      0},
 { INIT_WORD, 0xffff, USER_CH_2_Ar_NL_GAIN,     0},

 { INIT_WORD, 0x0000, USER_CH_3_Ar_I_GAIN,      0},
 { INIT_WORD, 0x0000, USER_CH_3_Ar_P_GAIN,      0},
 { INIT_WORD, 0x0000, USER_CH_3_Ar_D_GAIN,      0},
 { INIT_WORD, 0xffff, USER_CH_3_Ar_NL_GAIN,     0},

 { END,         0,      0,      0}  };


static const UPDATE_TABLE_ENTRY  INIT_LDID_PID_TABLE[] = {


 { INIT_PID,  0xffff, FACT_CH_3_N2_I_GAIN,      3},
 { INIT_PID,  0xffff, FACT_CH_3_N2_P_GAIN,      3},
 { INIT_PID,  0xffff, FACT_CH_3_N2_D_GAIN,      3},
 { INIT_PID,  0xffff, FACT_CH_3_N2_NL_GAIN,     3},

 { INIT_PID,  0x004f, FACT_CH_3_He_I_GAIN,      3},
 { INIT_PID,  0x0041, FACT_CH_3_He_P_GAIN,      3},
 { INIT_PID,  0x003c, FACT_CH_3_He_D_GAIN,      3},
 { INIT_PID,  0xffff, FACT_CH_3_He_NL_GAIN,     3},

 { INIT_PID,  0xffff, FACT_CH_3_Ar_I_GAIN,      3},
 { INIT_PID,  0xffff, FACT_CH_3_Ar_P_GAIN,      3},
 { INIT_PID,  0xffff, FACT_CH_3_Ar_D_GAIN,      3},
 { INIT_PID,  0xffff, FACT_CH_3_Ar_NL_GAIN,     3},

 { INIT_PID,  0xffff, FACT_CH_3_ArMe_I_GAIN,    3},
 { INIT_PID,  0xffff, FACT_CH_3_ArMe_P_GAIN,    3},
 { INIT_PID,  0xffff, FACT_CH_3_ArMe_D_GAIN,    3},
 { INIT_PID,  0xffff, FACT_CH_3_ArMe_NL_GAIN,   3},







 { INIT_WORD, 0x0000, USER_CH_1_N2_I_GAIN,      0},
 { INIT_WORD, 0x0000, USER_CH_1_N2_P_GAIN,      0},
 { INIT_WORD, 0x0000, USER_CH_1_N2_D_GAIN,      0},
 { INIT_WORD, 0xffff, USER_CH_1_N2_NL_GAIN,     0},

 { INIT_WORD, 0x0000, USER_CH_2_N2_I_GAIN,      0},
 { INIT_WORD, 0x0000, USER_CH_2_N2_P_GAIN,      0},
 { INIT_WORD, 0x0000, USER_CH_2_N2_D_GAIN,      0},
 { INIT_WORD, 0xffff, USER_CH_2_N2_NL_GAIN,     0},

 { INIT_WORD, 0x0000, USER_CH_3_N2_I_GAIN,      0},
 { INIT_WORD, 0x0000, USER_CH_3_N2_P_GAIN,      0},
 { INIT_WORD, 0x0000, USER_CH_3_N2_D_GAIN,      0},
 { INIT_WORD, 0xffff, USER_CH_3_N2_NL_GAIN,     0},

 { INIT_WORD, 0x0000, USER_CH_1_H2_I_GAIN,      0},
 { INIT_WORD, 0x0000, USER_CH_1_H2_P_GAIN,      0},
 { INIT_WORD, 0x0000, USER_CH_1_H2_D_GAIN,      0},
 { INIT_WORD, 0xffff, USER_CH_1_H2_NL_GAIN,     0},

 { INIT_WORD, 0x0000, USER_CH_2_H2_I_GAIN,      0},
 { INIT_WORD, 0x0000, USER_CH_2_H2_P_GAIN,      0},
 { INIT_WORD, 0x0000, USER_CH_2_H2_D_GAIN,      0},
 { INIT_WORD, 0xffff, USER_CH_2_H2_NL_GAIN,     0},

 { INIT_WORD, 0x0000, USER_CH_3_H2_I_GAIN,      0},
 { INIT_WORD, 0x0000, USER_CH_3_H2_P_GAIN,      0},
 { INIT_WORD, 0x0000, USER_CH_3_H2_D_GAIN,      0},
 { INIT_WORD, 0xffff, USER_CH_3_H2_NL_GAIN,     0},

 { INIT_WORD, 0x0000, USER_CH_1_He_I_GAIN,      0},
 { INIT_WORD, 0x0000, USER_CH_1_He_P_GAIN,      0},
 { INIT_WORD, 0x0000, USER_CH_1_He_D_GAIN,      0},
 { INIT_WORD, 0xffff, USER_CH_1_He_NL_GAIN,     0},

 { INIT_WORD, 0x0000, USER_CH_2_He_I_GAIN,      0},
 { INIT_WORD, 0x0000, USER_CH_2_He_P_GAIN,      0},
 { INIT_WORD, 0x0000, USER_CH_2_He_D_GAIN,      0},
 { INIT_WORD, 0xffff, USER_CH_2_He_NL_GAIN,     0},

 { INIT_WORD, 0x0000, USER_CH_3_He_I_GAIN,      0},
 { INIT_WORD, 0x0000, USER_CH_3_He_P_GAIN,      0},
 { INIT_WORD, 0x0000, USER_CH_3_He_D_GAIN,      0},
 { INIT_WORD, 0xffff, USER_CH_3_He_NL_GAIN,     0},

 { INIT_WORD, 0x0000, USER_CH_1_ArMe_I_GAIN,    0},
 { INIT_WORD, 0x0000, USER_CH_1_ArMe_P_GAIN,    0},
 { INIT_WORD, 0x0000, USER_CH_1_ArMe_D_GAIN,    0},
 { INIT_WORD, 0xffff, USER_CH_1_ArMe_NL_GAIN,   0},

 { INIT_WORD, 0x0000, USER_CH_2_ArMe_I_GAIN,    0},
 { INIT_WORD, 0x0000, USER_CH_2_ArMe_P_GAIN,    0},
 { INIT_WORD, 0x0000, USER_CH_2_ArMe_D_GAIN,    0},
 { INIT_WORD, 0xffff, USER_CH_2_ArMe_NL_GAIN,   0},

 { INIT_WORD, 0x0000, USER_CH_3_ArMe_I_GAIN,    0},
 { INIT_WORD, 0x0000, USER_CH_3_ArMe_P_GAIN,    0},
 { INIT_WORD, 0x0000, USER_CH_3_ArMe_D_GAIN,    0},
 { INIT_WORD, 0xffff, USER_CH_3_ArMe_NL_GAIN,   0},

 { INIT_WORD, 0x0000, USER_CH_2_O2_I_GAIN,      0},
 { INIT_WORD, 0x0000, USER_CH_2_O2_P_GAIN,      0},
 { INIT_WORD, 0x0000, USER_CH_2_O2_D_GAIN,      0},
 { INIT_WORD, 0xffff, USER_CH_2_O2_NL_GAIN,     0},

 { INIT_WORD, 0x0000, USER_CH_2_Air_I_GAIN,     0},
 { INIT_WORD, 0x0000, USER_CH_2_Air_P_GAIN,     0},
 { INIT_WORD, 0x0000, USER_CH_2_Air_D_GAIN,     0},
 { INIT_WORD, 0xffff, USER_CH_2_Air_NL_GAIN,    0},

 { INIT_WORD, 0x0000, USER_CH_2_Ar_I_GAIN,      0},
 { INIT_WORD, 0x0000, USER_CH_2_Ar_P_GAIN,      0},
 { INIT_WORD, 0x0000, USER_CH_2_Ar_D_GAIN,      0},
 { INIT_WORD, 0xffff, USER_CH_2_Ar_NL_GAIN,     0},

 { INIT_WORD, 0x0000, USER_CH_3_Ar_I_GAIN,      0},
 { INIT_WORD, 0x0000, USER_CH_3_Ar_P_GAIN,      0},
 { INIT_WORD, 0x0000, USER_CH_3_Ar_D_GAIN,      0},
 { INIT_WORD, 0xffff, USER_CH_3_Ar_NL_GAIN,     0},

 { END,         0,      0,      0}  };


static const UPDATE_TABLE_ENTRY  INIT_uECD2_PID_TABLE[] = {

 { INIT_PID,  0x0100, FACT_CH_3_N2_I_GAIN,      3},                     /* as per T.K.W  5/1/96 */
 { INIT_PID,  0x0100, FACT_CH_3_N2_P_GAIN,      3},                     /* as per T.K.W  5/1/96 */
 { INIT_PID,  0x0100, FACT_CH_3_N2_D_GAIN,      3},                     /* as per T.K.W  5/1/96 */
 { INIT_PID,  0xffff, FACT_CH_3_N2_NL_GAIN,     3},


 { INIT_PID,  0xffff, FACT_CH_3_He_I_GAIN,      3},                     /* He no good for ECD; too few valence electrons to capture */
 { INIT_PID,  0xffff, FACT_CH_3_He_P_GAIN,      3},
 { INIT_PID,  0xffff, FACT_CH_3_He_D_GAIN,      3},
 { INIT_PID,  0xffff, FACT_CH_3_He_NL_GAIN,     3},


 { INIT_PID,  0x0100, FACT_CH_3_ArMe_I_GAIN,    3},                     /* as per T.K.W  5/1/96 */
 { INIT_PID,  0x0100, FACT_CH_3_ArMe_P_GAIN,    3},                     /* as per T.K.W  5/1/96 */
 { INIT_PID,  0x0100, FACT_CH_3_ArMe_D_GAIN,    3},                     /* as per T.K.W  5/1/96 */
 { INIT_PID,  0xffff, FACT_CH_3_ArMe_NL_GAIN,   3},



 { INIT_WORD, 0x0000, USER_CH_1_N2_I_GAIN,      0},
 { INIT_WORD, 0x0000, USER_CH_1_N2_P_GAIN,      0},
 { INIT_WORD, 0x0000, USER_CH_1_N2_D_GAIN,      0},
 { INIT_WORD, 0xffff, USER_CH_1_N2_NL_GAIN,     0},

 { INIT_WORD, 0x0000, USER_CH_2_N2_I_GAIN,      0},
 { INIT_WORD, 0x0000, USER_CH_2_N2_P_GAIN,      0},
 { INIT_WORD, 0x0000, USER_CH_2_N2_D_GAIN,      0},
 { INIT_WORD, 0xffff, USER_CH_2_N2_NL_GAIN,     0},

 { INIT_WORD, 0x0000, USER_CH_3_N2_I_GAIN,      0},
 { INIT_WORD, 0x0000, USER_CH_3_N2_P_GAIN,      0},
 { INIT_WORD, 0x0000, USER_CH_3_N2_D_GAIN,      0},
 { INIT_WORD, 0xffff, USER_CH_3_N2_NL_GAIN,     0},

 { INIT_WORD, 0x0000, USER_CH_1_H2_I_GAIN,      0},
 { INIT_WORD, 0x0000, USER_CH_1_H2_P_GAIN,      0},
 { INIT_WORD, 0x0000, USER_CH_1_H2_D_GAIN,      0},
 { INIT_WORD, 0xffff, USER_CH_1_H2_NL_GAIN,     0},

 { INIT_WORD, 0x0000, USER_CH_2_H2_I_GAIN,      0},
 { INIT_WORD, 0x0000, USER_CH_2_H2_P_GAIN,      0},
 { INIT_WORD, 0x0000, USER_CH_2_H2_D_GAIN,      0},
 { INIT_WORD, 0xffff, USER_CH_2_H2_NL_GAIN,     0},

 { INIT_WORD, 0x0000, USER_CH_3_H2_I_GAIN,      0},
 { INIT_WORD, 0x0000, USER_CH_3_H2_P_GAIN,      0},
 { INIT_WORD, 0x0000, USER_CH_3_H2_D_GAIN,      0},
 { INIT_WORD, 0xffff, USER_CH_3_H2_NL_GAIN,     0},

 { INIT_WORD, 0x0000, USER_CH_1_He_I_GAIN,      0},
 { INIT_WORD, 0x0000, USER_CH_1_He_P_GAIN,      0},
 { INIT_WORD, 0x0000, USER_CH_1_He_D_GAIN,      0},
 { INIT_WORD, 0xffff, USER_CH_1_He_NL_GAIN,     0},

 { INIT_WORD, 0x0000, USER_CH_2_He_I_GAIN,      0},
 { INIT_WORD, 0x0000, USER_CH_2_He_P_GAIN,      0},
 { INIT_WORD, 0x0000, USER_CH_2_He_D_GAIN,      0},
 { INIT_WORD, 0xffff, USER_CH_2_He_NL_GAIN,     0},

 { INIT_WORD, 0x0000, USER_CH_3_He_I_GAIN,      0},
 { INIT_WORD, 0x0000, USER_CH_3_He_P_GAIN,      0},
 { INIT_WORD, 0x0000, USER_CH_3_He_D_GAIN,      0},
 { INIT_WORD, 0xffff, USER_CH_3_He_NL_GAIN,     0},

 { INIT_WORD, 0x0000, USER_CH_1_ArMe_I_GAIN,    0},
 { INIT_WORD, 0x0000, USER_CH_1_ArMe_P_GAIN,    0},
 { INIT_WORD, 0x0000, USER_CH_1_ArMe_D_GAIN,    0},
 { INIT_WORD, 0xffff, USER_CH_1_ArMe_NL_GAIN,   0},

 { INIT_WORD, 0x0000, USER_CH_2_ArMe_I_GAIN,    0},
 { INIT_WORD, 0x0000, USER_CH_2_ArMe_P_GAIN,    0},
 { INIT_WORD, 0x0000, USER_CH_2_ArMe_D_GAIN,    0},
 { INIT_WORD, 0xffff, USER_CH_2_ArMe_NL_GAIN,   0},

 { INIT_WORD, 0x0000, USER_CH_3_ArMe_I_GAIN,    0},
 { INIT_WORD, 0x0000, USER_CH_3_ArMe_P_GAIN,    0},
 { INIT_WORD, 0x0000, USER_CH_3_ArMe_D_GAIN,    0},
 { INIT_WORD, 0xffff, USER_CH_3_ArMe_NL_GAIN,   0},

 { INIT_WORD, 0x0000, USER_CH_2_O2_I_GAIN,      0},
 { INIT_WORD, 0x0000, USER_CH_2_O2_P_GAIN,      0},
 { INIT_WORD, 0x0000, USER_CH_2_O2_D_GAIN,      0},
 { INIT_WORD, 0xffff, USER_CH_2_O2_NL_GAIN,     0},

 { INIT_WORD, 0x0000, USER_CH_2_Air_I_GAIN,     0},
 { INIT_WORD, 0x0000, USER_CH_2_Air_P_GAIN,     0},
 { INIT_WORD, 0x0000, USER_CH_2_Air_D_GAIN,     0},
 { INIT_WORD, 0xffff, USER_CH_2_Air_NL_GAIN,    0},

 { INIT_WORD, 0x0000, USER_CH_2_Ar_I_GAIN,      0},
 { INIT_WORD, 0x0000, USER_CH_2_Ar_P_GAIN,      0},
 { INIT_WORD, 0x0000, USER_CH_2_Ar_D_GAIN,      0},
 { INIT_WORD, 0xffff, USER_CH_2_Ar_NL_GAIN,     0},

 { INIT_WORD, 0x0000, USER_CH_3_Ar_I_GAIN,      0},
 { INIT_WORD, 0x0000, USER_CH_3_Ar_P_GAIN,      0},
 { INIT_WORD, 0x0000, USER_CH_3_Ar_D_GAIN,      0},
 { INIT_WORD, 0xffff, USER_CH_3_Ar_NL_GAIN,     0},

 { END,         0,      0,      0}  };

/**begin_proto**/

void WriteDetPIDs ( U_INT8 module, EEPROM_DET_TYPE type )

/**end_proto**/
{

   switch ( (EEPROM_DET_TYPE)((U_INT16)type & 0x00ff) )
   {
      case EPC_FID:UpdateEeprom( module, (pUPDATE_TABLE)INIT_FID_PID_TABLE );
               break;

      case EPC_TCD:UpdateEeprom( module, (pUPDATE_TABLE)INIT_TCD_PID_TABLE );
               break;

      case EPC_NPD:UpdateEeprom( module, (pUPDATE_TABLE)INIT_NPD_PID_TABLE );
               break;

      case EPC_ECD:UpdateEeprom( module, (pUPDATE_TABLE)INIT_ECD_PID_TABLE );
               break;

      case EPC_FPD:UpdateEeprom( module, (pUPDATE_TABLE)INIT_FPD_PID_TABLE );
               break;

      case EPC_uECD:UpdateEeprom( module, (pUPDATE_TABLE)INIT_uECD_PID_TABLE );
               break;

      case EPC_uECD2:UpdateEeprom( module, (pUPDATE_TABLE)INIT_uECD2_PID_TABLE );
               break;

      case EPC_LDID:UpdateEeprom( module, (pUPDATE_TABLE)INIT_LDID_PID_TABLE );
               break;

   }

}


static const UPDATE_TABLE_ENTRY  D_0109_Update[] = {
  { INIT_WORD, 0x0109, 0x01,   0 },      /* update the version field */
  { END,       0,      0,      0 } };

/**begin_proto**/

void UpdateDetEeprom109( pDETECTOR_STATUS status )

/**end_proto**/
{

    UpdateEeprom( status->Module_Number, (pUPDATE_TABLE)D_0109_Update );

}


static const UPDATE_TABLE_ENTRY  D_010A_Update[] = {

  { SAVE_WORD, 0x02,   0,      0 },       /* save the module type word */

  { INIT_WORD, 0xffff, 0x02,   0 },       /* scribble module type in case of failure */

  /* update for new scaling values */

  { SHIFT_32,  7,      0x8a,   0x8d },    /* Fuel H2 frit 1 * 512 */
  { SHIFT_32,  7,      0x90,   0x93 },    /* Fuel H2 frit 2 * 512 */
  { SHIFT_32,  7,      0x8b,   0x8e },    /* Util N2 frit 1 * 512 */
  { SHIFT_32,  7,      0x91,   0x94 },    /* Util N2 frit 2 * 512 */
  { SHIFT_32,  7,      0x8c,   0x8f },    /* Mug  N2 frit 1 * 512 */
  { SHIFT_32,  7,      0x92,   0x95 },    /* Mug  N2 frit 2 * 512 */
  { SHIFT_32,  7,      0x97,   0x9a },    /* Util He frit 1 * 512 */
  { SHIFT_32,  7,      0x9d,   0xa0 },    /* Util He frit 2 * 512 */
  { SHIFT_32,  7,      0x98,   0x9b },    /* Mug  He frit 1 * 512 */
  { SHIFT_32,  7,      0x9e,   0xa1 },    /* Mug  He frit 2 * 512 */
  { SHIFT_32,  7,      0xa3,   0xa6 },    /* Util H2 frit 1 * 512 */
  { SHIFT_32,  7,      0xa9,   0xac },    /* Util H2 frit 2 * 512 */
  { SHIFT_32,  7,      0xa4,   0xa7 },    /* Mug  H2 frit 1 * 512 */
  { SHIFT_32,  7,      0xaa,   0xad },    /* Mug  H2 frit 2 * 512 */
  { SHIFT_32,  7,      0xaf,   0xb2 },    /* Util Ar frit 1 * 512 */
  { SHIFT_32,  7,      0xb5,   0xb8 },    /* Util Ar frit 2 * 512 */
  { SHIFT_32,  7,      0xb0,   0xb3 },    /* Mug  Ar frit 1 * 512 */
  { SHIFT_32,  7,      0xb6,   0xb9 },    /* Mug  Ar frit 2 * 512 */

  { INIT_WORD, 0x010a, 0x01,   0 },      /* write the new version code */

  { RESTORE_WORD, 0,   0x02,   0 },      /* return the module type word */

  { END,       0,      0,      0 } };



/**begin_proto**/

void UpdateDetEeprom10A( pDETECTOR_STATUS status )

/**end_proto**/
{

    UpdateEeprom( status->Module_Number, (pUPDATE_TABLE)D_010A_Update );

}


static const UPDATE_TABLE_ENTRY  D_010B_Update[] = {

  { SAVE_WORD, 0x02,   0,      0 },       /* save the module type word */

  { INIT_WORD, 0xffff, 0x02,   0 },       /* scribble module type in case of failure */

  { COPY_BLOCK, 0xae,  0xbd,  12 },       /* last block, frit constants */
  { COPY_BLOCK, 0xa2,  0xae,  12 },       /* third block, frit constants */
  { COPY_BLOCK, 0x96,  0x9f,  12 },       /* 2cond block, frit constants */
  { COPY_BLOCK, 0x8a,  0x90,  12 },       /* first block, frit constants */

  { COPY_BLOCK, 0x2a,  0x30,  96 },       /* pid terms */

  { COPY_BLOCK, 0x18,  0x1e,  18 },       /* calib constants */

  { INIT_ROW,   0x0012,0x1b,   0 },       /* update the three scaling words */

  { INIT_WORD, 0x010b, 0x01,   0 },      /* write the new version code */

  { RESTORE_WORD, 0,   0x02,   0 },      /* return the module type word */

  { END,       0,      0,      0 } };



/**begin_proto**/

void UpdateDetEeprom10B( pDETECTOR_STATUS status )

/**end_proto**/
{

    UpdateEeprom( status->Module_Number, (pUPDATE_TABLE)D_010B_Update );
    WriteDetPsRange( status->Module_Number );

}


static const UPDATE_TABLE_ENTRY  D_010C_Update[] = {

  { INIT_WORD, 0x010c, 0x01,   0 },      /* write the new version code */

  { END,       0,      0,      0 } };


/**begin_proto**/

void UpdateDetEeprom10C( pDETECTOR_STATUS status )

/**end_proto**/
{
    UpdateEeprom( status->Module_Number, (pUPDATE_TABLE)D_010C_Update );
}

/**begin_proto**/

UI_ERR GetDetEepromDef (U_INT16 address, BIT8 *definition )

/**end_proto**/
{

    U_INT8 i;

    if ( address >= DET_EEPROM_SIZE ) return INVALID_PARAM;

    for ( i = 0 ; i < EEPROM_DEF_SIZE ; i++ )  definition[i] = Det_EEPROM_Default[address].definition[i];

    return OK;

}

static const UPDATE_TABLE_ENTRY  D_010D_Update[] = {

  { INIT_WORD, 0x010d, 0x01,   0 },      /* write the new version code */

  { END,       0,      0,      0 } };


/**begin_proto**/

void UpdateDetEeprom10D( pDETECTOR_STATUS status )

/**end_proto**/
{

    UpdateEeprom( status->Module_Number, (pUPDATE_TABLE)D_010D_Update );
}


static const UPDATE_TABLE_ENTRY  D_010E_Update[] = {

  { CALC_CKSUM, 0,      0,      0 },       /* calc and write the module cksum    */

  { INIT_WORD, 0x010e, 0x01,   0 },      /* write the new version code */

  { END,       0,      0,      0 } };


/**begin_proto**/

void UpdateDetEeprom10E( pDETECTOR_STATUS status )

/**end_proto**/
{

    UpdateEeprom( status->Module_Number, (pUPDATE_TABLE)D_010E_Update );
}


static const UPDATE_TABLE_ENTRY  D_010F_Update[] = {


  { INIT_WORD, 0x010f, 0x01,   0 },      /* write the new version code */

  { END,       0,      0,      0 } };


/**begin_proto**/

void UpdateDetEeprom10F( pDETECTOR_STATUS status )

/**end_proto**/
{
    UpdateEeprom( status->Module_Number, (pUPDATE_TABLE)D_010F_Update );
}



static const UPDATE_TABLE_ENTRY  D_0110_Update[] = {


  { INIT_WORD, 0x0110, 0x01,   0 },      /* write the new version code */

  { END,       0,      0,      0 } };


/**begin_proto**/

void UpdateDetEeprom110( pDETECTOR_STATUS status )

/**end_proto**/
{

    UpdateEeprom( status->Module_Number, (pUPDATE_TABLE)D_0110_Update );
}



static const UPDATE_TABLE_ENTRY  D_0111_Update[] = {


  { INIT_WORD, 0x0111, 0x01,   0 },      /* write the new version code */

  { END,       0,      0,      0 } };


/**begin_proto**/

void UpdateDetEeprom111( pDETECTOR_STATUS status )

/**end_proto**/
{

    UpdateEeprom( status->Module_Number, (pUPDATE_TABLE)D_0111_Update );
}




static const UPDATE_TABLE_ENTRY  D_0200_Update[] = {


  { INIT_WORD, 0x0200, 0x01,   0 },      /* write the new version code */

  { END,       0,      0,      0 } };


/**begin_proto**/

void UpdateDetEeprom200( pDETECTOR_STATUS status )

/**end_proto**/
{

    WriteDetMaxFlows( status->Module_Number );
    WriteDetMinFlows( status->Module_Number );

    WriteDetPIDs( status->Module_Number, status->Config->Type );

    UpdateEeprom( status->Module_Number, (pUPDATE_TABLE)D_0200_Update );
}
